From 8cd36e036a614916b5632514a29496089a766243 Mon Sep 17 00:00:00 2001 From: Justin Linenkohl <83235841+jlinenkohl@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:17:00 -0400 Subject: [PATCH] feat(clone): add --yes so the bash path can run unattended like the PowerShell one Clone-Agent.ps1 takes -Force. clone-agent.sh has no equivalent, so the only way to drive it unattended is to pipe something into stdin -- and that stdin is inherited by every child process it spawns. Both available workarounds fail. Piping a single line leaves the later `read` at EOF, which `set -e` turns into a silent exit before deployment. Piping an endless stream, `yes | ./clone-agent.sh ...`, makes `az rest` hang indefinitely: the same call returns in two seconds with stdin on /dev/null and never returns when stdin is an endless stream. Two export runs stalled for over two hours on a single GET that normally takes two seconds, with no output and no error. That is easy to mistake for the bash path simply being slow, which it is not -- the PowerShell path completed the same export unattended because -Force meant nothing had to be piped at it. -y / --yes / --force skips the prompt directly, so stdin can stay closed. --- sreagent-templates/bin/clone-agent.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sreagent-templates/bin/clone-agent.sh b/sreagent-templates/bin/clone-agent.sh index b863b265b..949fbe336 100755 --- a/sreagent-templates/bin/clone-agent.sh +++ b/sreagent-templates/bin/clone-agent.sh @@ -50,6 +50,7 @@ Optional: --override connectors.0.properties.dataSource=/subscriptions/.../new-ai --backend Deploy backend: bicep (default) or terraform --validate-only Run all validation checks without deploying + -y, --yes, --force Do not prompt before deploying (for unattended runs) --skip-extras Deploy Bicep only, skip data-plane config -h, --help Show this help EOF @@ -57,7 +58,7 @@ EOF } SOURCE="" EXTRAS="" SECRETS="" NEW_AGENT="" NEW_RG="" NEW_LOC="" NEW_TARGET_RGS="" -NEW_SUB="" NEW_ACCESS="" NEW_ACTION="" VALIDATE_ONLY=false SKIP_EXTRAS=false +NEW_SUB="" NEW_ACCESS="" NEW_ACTION="" VALIDATE_ONLY=false SKIP_EXTRAS=false ASSUME_YES=false FROM_AGENT="" FROM_RG="" FROM_SUB="" BACKEND="bicep" declare -a OVERRIDES=() @@ -79,6 +80,7 @@ while [[ $# -gt 0 ]]; do --override) OVERRIDES+=("$2"); shift 2 ;; --backend) BACKEND="$2"; shift 2 ;; --validate-only) VALIDATE_ONLY=true; shift ;; + -y|--yes|--force) ASSUME_YES=true; shift ;; --skip-extras) SKIP_EXTRAS=true; shift ;; -h|--help) usage 0 ;; *) echo "Unknown option: $1" >&2; usage 1 ;; @@ -610,8 +612,16 @@ if [[ "$VALIDATE_ONLY" == "true" ]]; then fi echo -read -rp " Proceed with deployment? [y/N] " confirm -[[ "$confirm" =~ ^[Yy]$ ]] || { echo "Aborted."; exit 0; } +# Clone-Agent.ps1 has -Force; this is the same thing. Without it the only way to drive the +# script unattended is to pipe something into stdin, and that stdin is inherited by every +# child process -- piping an endless stream (`yes |`) makes `az rest` hang indefinitely, +# while piping a single line leaves `read` at EOF, which `set -e` turns into an exit. +if [[ "$ASSUME_YES" == "true" ]]; then + echo " Proceeding with deployment (--yes)." +else + read -rp " Proceed with deployment? [y/N] " confirm + [[ "$confirm" =~ ^[Yy]$ ]] || { echo "Aborted."; exit 0; } +fi echo