diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-05 22:57:10 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-05 22:57:10 +0300 |
| commit | ebf564c546f081734c612c481857fc4ab30f1b9a (patch) | |
| tree | 6e9d8d74694b1146586a5b524fd6537f98c87bf9 /src | |
| parent | ce3c1f9ffeffc0b57f46fc21ff1505581d0d199e (diff) | |
Fix init config template path replacement
Diffstat (limited to 'src')
| -rwxr-xr-x | src/photoalbum.sh | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/photoalbum.sh b/src/photoalbum.sh index afa4ae9..f33f386 100755 --- a/src/photoalbum.sh +++ b/src/photoalbum.sh @@ -218,6 +218,7 @@ apply_template_dir_default() { init_config() { local -r rc_file=photoalbum.conf local default_rc_file + local rewritten_rc_file local source_root local source_template_dir @@ -239,8 +240,18 @@ init_config() { if [[ -n "$source_root" \ && "$default_rc_file" = "$source_root/src/photoalbum.default.conf" ]]; then source_template_dir="$source_root/share/templates/default" - sed -i "s#^TEMPLATE_DIR=.*#TEMPLATE_DIR=$source_template_dir#" \ - "$rc_file" + rewritten_rc_file=$(mktemp "${rc_file}.XXXXXX") + if ! awk -v template_dir="$source_template_dir" \ + '/^TEMPLATE_DIR=/ { + print "TEMPLATE_DIR=" template_dir + next + } + { print }' "$rc_file" > "$rewritten_rc_file"; then + rm -f "$rewritten_rc_file" + exit 1 + fi + cat "$rewritten_rc_file" > "$rc_file" + rm -f "$rewritten_rc_file" fi log_info "Created ./$rc_file" |
