From cd6f38a2e8d5b2f4198831aae0a37c568c69c2ae Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 8 Aug 2022 10:01:32 -0400 Subject: Ensure BIZ_ROOT is set in shell scripts --- Biz/Ide/ftags | 2 +- Biz/Ide/hooks/post-checkout | 2 +- Biz/Ide/hooks/post-merge | 2 +- Biz/Ide/hooks/pre-commit | 2 +- Biz/Ide/hooks/pre-push | 2 +- Biz/Ide/mktags | 14 +++++++------- Biz/Ide/ns | 2 +- Biz/Ide/push | 4 ++-- Biz/Ide/repl | 6 +++--- Biz/Ide/run | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Biz/Ide/ftags b/Biz/Ide/ftags index 929399f..bc4fda0 100755 --- a/Biz/Ide/ftags +++ b/Biz/Ide/ftags @@ -3,7 +3,7 @@ # search tags with fzf # set -euo pipefail - tags=$BIZ_ROOT/tags + tags=${BIZ_ROOT:?}/tags tag_search=$( awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' "$tags" \ | cut -c1-80 \ diff --git a/Biz/Ide/hooks/post-checkout b/Biz/Ide/hooks/post-checkout index 95b35cd..9328c35 100755 --- a/Biz/Ide/hooks/post-checkout +++ b/Biz/Ide/hooks/post-checkout @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -e -init_tags=$BIZ_ROOT/Biz/Ide/init_tags.sh +init_tags=${BIZ_ROOT:?}/Biz/Ide/init_tags.sh old=$1 new=$2 # filter out only the changed haskell files diff --git a/Biz/Ide/hooks/post-merge b/Biz/Ide/hooks/post-merge index 624e797..8aa530e 100755 --- a/Biz/Ide/hooks/post-merge +++ b/Biz/Ide/hooks/post-merge @@ -1,2 +1,2 @@ #!/usr/bin/env bash -exec $BIZ_ROOT/Biz/Ide/post-checkout 'HEAD@{1}' HEAD +exec ${BIZ_ROOT:?}/Biz/Ide/post-checkout 'HEAD@{1}' HEAD diff --git a/Biz/Ide/hooks/pre-commit b/Biz/Ide/hooks/pre-commit index fe4bbe3..065a0f6 100755 --- a/Biz/Ide/hooks/pre-commit +++ b/Biz/Ide/hooks/pre-commit @@ -7,7 +7,7 @@ changed=($(git diff-index --cached --name-only HEAD)) for ns in ${changed[@]} do - version=$($BIZ_ROOT/Biz/Ide/version $ns) + version=$(${BIZ_ROOT:?}/Biz/Ide/version $ns) if (( $version == -1 )); then echo "info: version: $ns: deleted" elif (( $version < 1 )); then diff --git a/Biz/Ide/hooks/pre-push b/Biz/Ide/hooks/pre-push index 5236651..c27046d 100755 --- a/Biz/Ide/hooks/pre-push +++ b/Biz/Ide/hooks/pre-push @@ -1,2 +1,2 @@ #!/usr/bin/env bash -lint "$BIZ_ROOT"/**/* && bild --test "$BIZ_ROOT"/**/* +lint "${BIZ_ROOT:?}"/**/* && bild --test "${BIZ_ROOT:?}"/**/* diff --git a/Biz/Ide/mktags b/Biz/Ide/mktags index c8c1f99..ebad39a 100755 --- a/Biz/Ide/mktags +++ b/Biz/Ide/mktags @@ -4,17 +4,17 @@ # set -euxo pipefail files=$@ - vimtags=$BIZ_ROOT/tags - emacstags=$BIZ_ROOT/TAGS + vimtags=${BIZ_ROOT:?}/tags + emacstags=${BIZ_ROOT:?}/TAGS # if [[ ! -r $emacstags ]]; then echo Generating emacs TAGS from scratch... - fast-tags -e -R $BIZ_ROOT + fast-tags -e -R ${BIZ_ROOT:?} ctags -e \ --append=yes \ --recurse=yes \ --exclude="$BIZ_ROOT/_/*" \ - $BIZ_ROOT + ${BIZ_ROOT:?} else fast-tags -e $files ctags -e \ @@ -25,12 +25,12 @@ # if [[ ! -r $vimtags ]]; then echo Generating vim tags from scratch... - fast-tags "${flags[@]}" -R $BIZ_ROOT + fast-tags "${flags[@]}" -R ${BIZ_ROOT:?} ctags "${flags[@]}" \ --append=yes \ --recurse=yes \ - --exclude="$BIZ_ROOT/_/*" \ - $BIZ_ROOT + --exclude="${BIZ_ROOT:?}/_/*" \ + ${BIZ_ROOT:?} else fast-tags "${flags[@]}" $files ctags "${flags[@]}" \ diff --git a/Biz/Ide/ns b/Biz/Ide/ns index 8ca8d98..c32b5d2 100755 --- a/Biz/Ide/ns +++ b/Biz/Ide/ns @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -fd --exclude=_ -t f . $BIZ_ROOT | sed "s,$BIZ_ROOT/*,,g" \ +fd --exclude=_ -t f . ${BIZ_ROOT:?} | sed "s,${BIZ_ROOT:?}/*,,g" \ | fzf \ --bind "alt-space:execute(bild {} && read -p [fin])" \ --bind "alt-enter:execute(vim {})" \ diff --git a/Biz/Ide/push b/Biz/Ide/push index f6b9b98..7ace897 100755 --- a/Biz/Ide/push +++ b/Biz/Ide/push @@ -2,14 +2,14 @@ # Eventually convert to haskell, see: # - https://github.com/awakesecurity/nix-deploy/blob/master/src/Main.hs # - http://www.haskellforall.com/2018/08/nixos-in-production.html -prefix=$(echo $PWD | sed -e "s|^$BIZ_ROOT/*||g") +prefix=$(echo $PWD | sed -e "s|^${BIZ_ROOT:?}/*||g") if [[ "$prefix" == "" ]] then target="$1" else target="$prefix.$1" fi -what=$(realpath "$BIZ_ROOT/_/nix/$target") +what=$(realpath "${BIZ_ROOT:?}/_/nix/$target") # hack: get the domain from the activation script. there does not seem # to be a way to get it from nix-instantiate where=$(rg -r '$2' -e '(domainname ")(.*)(")' "$what/activate") diff --git a/Biz/Ide/repl b/Biz/Ide/repl index 8f92fba..c6259e1 100755 --- a/Biz/Ide/repl +++ b/Biz/Ide/repl @@ -29,7 +29,7 @@ fi langdeps=$(jq --raw-output '.[].langdeps | join(" ")' <<< $json) sysdeps=$(jq --raw-output '.[].sysdeps | join(" ")' <<< $json) exts=$(jq --raw-output '.[].namespace.ext' <<< $json | sort | uniq) - BILD="(import $BIZ_ROOT/Biz/Bild.nix {})" + BILD="(import ${BIZ_ROOT:?}/Biz/Bild.nix {})" for lib in ${sysdeps[@]}; do flags+=(--packages "$BILD.private.nixpkgs.${lib}") flags+=(--packages "$BILD.private.nixpkgs.pkg-config") @@ -44,14 +44,14 @@ fi echo "warn: repl: ghci does not support binding to a port" fi flags+=(--packages "$BILD.private.ghcWith (h: with h; [$langdeps])") - command=${CMD:-"ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci ${targets[@]}"} + command=${CMD:-"ghci -i${BIZ_ROOT:?} -ghci-script ${BIZ_ROOT:?}/.ghci ${targets[@]}"} ;; Scm) for lib in ${langdeps[@]}; do flags+=(--packages "$BILD.private.nixpkgs.guile-${lib}") done flags+=(--packages "$BILD.private.nixpkgs.guile_3_0") - command=${CMD:-"guile -L $BIZ_ROOT -C $BIZ_ROOT/_/int --r7rs --listen=${PORT:-37146}"} + command=${CMD:-"guile -L ${BIZ_ROOT:?} -C ${BIZ_ROOT:?}/_/int --r7rs --listen=${PORT:-37146}"} ;; Lisp) flags+=(--packages "$BILD.private.sbclWith (p: with p; [asdf swank $langdeps])") diff --git a/Biz/Ide/run b/Biz/Ide/run index 49cd72d..bf35e3e 100755 --- a/Biz/Ide/run +++ b/Biz/Ide/run @@ -3,4 +3,4 @@ set -eu target=$1 shift out=$(rg --only-matching ": out (\w*)" -r '$1' $target) -exec "$BIZ_ROOT/_/bin/$out" "$@" +exec "${BIZ_ROOT:?}/_/bin/$out" "$@" -- cgit v1.2.3