From c4a3e0249e6f6b6a97c6feebb68ca4bbcffaaa91 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Fri, 2 Jun 2023 12:52:53 +0200 Subject: [PATCH] archive-fonts: Make PWD independent [why] Scripts should run regardless of current working directory. Signed-off-by: Fini Jastrow --- bin/scripts/archive-fonts.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/scripts/archive-fonts.sh b/bin/scripts/archive-fonts.sh index 08323a995..7689645c8 100755 --- a/bin/scripts/archive-fonts.sh +++ b/bin/scripts/archive-fonts.sh @@ -12,13 +12,12 @@ set -e LINE_PREFIX="# [Nerd Fonts] " -scripts_root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" -parent_dir="${PWD}/../../" -outputdir=$scripts_root_dir../../archives +root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}/../..")" >/dev/null 2>&1 || exit && pwd -P)" +outputdir=${root_dir}/archives mkdir -p "$outputdir" -cd "$scripts_root_dir/../../patched-fonts/" || { +cd "${root_dir}/patched-fonts/" || { echo >&2 "$LINE_PREFIX Could not find patched fonts directory" exit 1 } @@ -37,7 +36,7 @@ fi # create a mini readme with basic info on Nerd Fonts project touch "$outputdir/readme.md" mini_readme="$outputdir/readme.md" -cat "$parent_dir/src/archive-readme.md" >> "$mini_readme" +cat "$root_dir/src/archive-readme.md" >> "$mini_readme" # clear out the directory zips find "${outputdir:?}" -name "$search_pattern" -type f -delete