diff --git a/src/utility.sh b/src/utility.sh index 99746a7..dacb48a 100644 --- a/src/utility.sh +++ b/src/utility.sh @@ -16,9 +16,21 @@ log() { set_opts() { sign="$1" - set "${sign}o" errexit - set "${sign}o" nounset - set "${sign}o" pipefail + set_opt() { + local opt="$1" + + if set -o | grep -q "^$opt[[:space:]]"; then + set "${sign}o" "$opt" + log debug "[set_opts] Set: $(set -o | grep -q "^$opt[[:space:]]")" + else + log fatal "Unsupported shell: no $opt option support" + return 1 + fi + } + + set_opt errexit + set_opt nounset + set_opt pipefail } prepare_directories() { diff --git a/tori b/tori index 261c82b..29a5efd 100755 --- a/tori +++ b/tori @@ -2,17 +2,13 @@ main() { # paths - VERSION="0.4.1 2024-07-14" + VERSION="0.5.0 2024-07-18" TORI_ROOT="$HOME/.local/share/tori" CONFIG_ROOT="$HOME/.config/tori" TMP_DIR="/tmp/tori" CACHE_DIR="$HOME/.cache/tori" - check_core_paths - - . "$TORI_ROOT/src/index.sh" - - # state + # os-independent state DEBUG=$DEBUG @@ -20,13 +16,16 @@ main() { argument="$1" parameter="$2" + # import source + + check_core_paths + . "$TORI_ROOT/src/index.sh" set_opts - - ## global constants + ## os-dependent state OS="$(get_operating_system)" PACKAGE_CACHE="$CACHE_DIR/${OS}_packages.cache" - ## global state base_files= bkp_files= user_packages=