summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-03 19:48:31 +0300
committerPaul Buetow <paul@buetow.org>2026-06-03 19:48:31 +0300
commit11da40444ce1bf74545f87a4bfe339f61b4660f0 (patch)
tree9d95ad210f9685a1fde54fc3cdf80b2ee280853d /src
parentda8b0d3ba6d27c17f511da0284db8ae44e5e906b (diff)
Fix TAR_OPTS argv handling for si0
Diffstat (limited to 'src')
-rw-r--r--src/photoalbum.default.conf2
-rwxr-xr-xsrc/photoalbum.sh36
2 files changed, 34 insertions, 4 deletions
diff --git a/src/photoalbum.default.conf b/src/photoalbum.default.conf
index 51b2118..4c581de 100644
--- a/src/photoalbum.default.conf
+++ b/src/photoalbum.default.conf
@@ -19,7 +19,7 @@ TEMPLATE_DIR=/usr/share/photoalbum/templates/default
# Includes a .tar of the incoming dir in the dist, can be yes or no
TARBALL_INCLUDE=yes
TARBALL_SUFFIX=.tar
-TAR_OPTS='-c'
+TAR_OPTS=(-c)
# Some debugging options
#set -e
diff --git a/src/photoalbum.sh b/src/photoalbum.sh
index 88b6cfb..e2beffb 100755
--- a/src/photoalbum.sh
+++ b/src/photoalbum.sh
@@ -134,21 +134,49 @@ imagemagick() {
tarball() {
local -r tarball_name="$1"; shift
- local -r tar_opts="${TAR_OPTS:--c}"
local base
+ local -a tar_opts=()
# Cleanup tarball from prev run if any
find "$DIST_DIR" -maxdepth 1 -type f -name '*.tar' -delete
base=$(basename "$INCOMING_DIR")
+ resolve_tar_opts tar_opts
log_info "Creating tarball $(_display_path "$DIST_DIR/$tarball_name")" \
"from $INCOMING_DIR"
(
cd "$(dirname "$INCOMING_DIR")"
- tar "$tar_opts" -f "$DIST_DIR/$tarball_name" "$base"
+ tar "${tar_opts[@]}" -f "$DIST_DIR/$tarball_name" "$base"
)
}
+resolve_tar_opts() {
+ local -n options_ref="$1"; shift
+ local tar_opts_decl
+
+ options_ref=()
+
+ if ! tar_opts_decl=$(declare -p TAR_OPTS 2>/dev/null); then
+ options_ref=(-c)
+ return
+ fi
+
+ case "$tar_opts_decl" in
+ declare\ -a*\ TAR_OPTS=*)
+ options_ref=("${TAR_OPTS[@]}")
+ ;;
+ *)
+ if [ -n "${TAR_OPTS:-}" ]; then
+ read -r -a options_ref <<< "$TAR_OPTS"
+ fi
+ ;;
+ esac
+
+ if (( ${#options_ref[@]} == 0 )); then
+ options_ref=(-c)
+ fi
+}
+
_html_escape() {
local text="$1"; shift
@@ -1000,7 +1028,9 @@ apply_config_defaults() {
SHUFFLE="${SHUFFLE:-no}"
TARBALL_INCLUDE="${TARBALL_INCLUDE:-no}"
TARBALL_SUFFIX="${TARBALL_SUFFIX:-.tar}"
- TAR_OPTS="${TAR_OPTS:--c}"
+ if ! declare -p TAR_OPTS >/dev/null 2>&1; then
+ TAR_OPTS=(-c)
+ fi
}
option_value() {