From 30c6bc22a445105e7e7f37fb00ca054de1ecf3ad Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 19 Oct 2026 19:11:13 +0200 Subject: 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 --- sbshadow | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sbshadow') 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 -- cgit v1.2.3