aboutsummaryrefslogtreecommitdiffstats
path: root/sbshadow
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-19 19:11:13 +0200
committerDanilo M. <danix@danix.xyz>2026-10-19 19:11:13 +0200
commit30c6bc22a445105e7e7f37fb00ca054de1ecf3ad (patch)
tree025a4df9a930434f528985d379afb1762fca10ec /sbshadow
parent0679099f804000123f2999ce07948d324305d998 (diff)
downloadslackrepo_setup-30c6bc22a445105e7e7f37fb00ca054de1ecf3ad.tar.gz
slackrepo_setup-30c6bc22a445105e7e7f37fb00ca054de1ecf3ad.zip
sbshadow: add --yes/--no, sbpull: pass flag, return sbshadow status
sbshadow --yes applies the plan without asking, --no shows it and leaves the tree unchanged, so non-interactive callers (sb-builder runs it as a detached job with no stdin) never hit the prompt. No flag keeps the interactive prompt. SBO_REPO overrides the repo path for testing. sbpull passes the flag on, and now returns sbshadow's exit status instead of popd's, which made a failed sbshadow look successful. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'sbshadow')
-rwxr-xr-xsbshadow22
1 files changed, 20 insertions, 2 deletions
diff --git a/sbshadow b/sbshadow
index b928df1..25cf923 100755
--- a/sbshadow
+++ b/sbshadow
@@ -13,10 +13,24 @@
# phantom-dep hintfiles with mkhint -F.
#
# Called by slackrepo_setup_SBo-danix.sh and by sbpull after a subtree pull.
+#
+# Usage: sbshadow [--yes|--no]
+# no flag show the plan and ask before changing anything
+# --yes apply the plan without asking
+# --no show the plan only, tree unchanged (preview)
+# SBO_REPO overrides the repo path (used to test against a throwaway repo).
set -euo pipefail
-REPO="/var/lib/sbopkg/SBo-danix"
+answer=""
+case "${1:-}" in
+ --yes) answer=y ;;
+ --no) answer=n ;;
+ "") ;;
+ *) echo "usage: sbshadow [--yes|--no]" >&2; exit 2 ;;
+esac
+
+REPO="${SBO_REPO:-/var/lib/sbopkg/SBo-danix}"
UPSTREAM="current"
cd "$REPO"
@@ -47,7 +61,11 @@ else
(( ${#to_restore[@]} )) && printf 'unshadow: %s\n' "${to_restore[@]}"
echo
- read -rp "Proceed? [y/N] " confirm
+ if [[ -n $answer ]]; then
+ confirm=$answer
+ else
+ read -rp "Proceed? [y/N] " confirm
+ fi
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "sbshadow: aborted, tree unchanged."
else