From d294607b12b5b54ebdcf0d93ef7ed6baa759fa35 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 28 Aug 2024 09:30:07 +0200 Subject: [PATCH] cheatsheet.sh: Make CWD independent [why] Sometimes people like to call the scripts from any directory and do not want to change into the bin/scripts/ directory first. [how] Just access the lib files relative to the cheatsheet script file. Signed-off-by: Fini Jastrow --- bin/scripts/cheatsheet.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/scripts/cheatsheet.sh b/bin/scripts/cheatsheet.sh index 761260696..fddf2da55 100755 --- a/bin/scripts/cheatsheet.sh +++ b/bin/scripts/cheatsheet.sh @@ -5,8 +5,11 @@ # Search for a glyph by part of its name in all patchsets # Usage: ./cheatsheet.sh divider +# Get script directory to set source and target dirs relative to it +sd="$( cd -- "$(dirname "${0}")" >/dev/null 2>&1 || exit ; pwd -P )" + # shellcheck disable=SC1091 # Do not pull in the sourced file -source ./lib/i_all.sh +source "${sd}/lib/i_all.sh" # Search the key on the declared variables for glyph in ${!i_*}; do