Description
A while [[ $# -gt 0 ]]; do case ... shift 2 ... esac; done loop that should iterate 5 times hits MaxLoopIterations(100000), suggesting the loop counter isn't decrementing or the loop condition isn't being re-evaluated correctly after shift.
Reproduction
#!/bin/bash
set -e
while [[ $# -gt 0 ]]; do
case $1 in
--name)
NAME="$2"
shift 2
;;
--value)
VALUE="$2"
shift 2
;;
*)
echo "Unknown: $1"
exit 1
;;
esac
done
echo "name=$NAME value=$VALUE"
Called as: script.sh --name foo --value bar (should iterate 2 times, shifting 2 each)
Expected: Prints name=foo value=bar, exits 0
Actual: ResourceLimit(MaxLoopIterations(100000))
Source
Found in microsoft-foundry/generate_deployment_url.sh (microsoft/github-copilot-for-azure) — the while/case argument parsing pattern is the most common pattern in skills scripts.
Cross-ref: tests/skills_tests.rs::exec_azure_generate_url (ignored, reproduces the bug)
Notes
The same pattern works in exec_azure_discover_rank which also uses while/case, so the issue may be specific to script file execution context (the failing test writes the script to VFS and executes it as a file, while the passing test also does this but has a different script structure).
Description
A
while [[ $# -gt 0 ]]; do case ... shift 2 ... esac; doneloop that should iterate 5 times hitsMaxLoopIterations(100000), suggesting the loop counter isn't decrementing or the loop condition isn't being re-evaluated correctly aftershift.Reproduction
Called as:
script.sh --name foo --value bar(should iterate 2 times, shifting 2 each)Expected: Prints
name=foo value=bar, exits 0Actual:
ResourceLimit(MaxLoopIterations(100000))Source
Found in
microsoft-foundry/generate_deployment_url.sh(microsoft/github-copilot-for-azure) — the while/case argument parsing pattern is the most common pattern in skills scripts.Cross-ref:
tests/skills_tests.rs::exec_azure_generate_url(ignored, reproduces the bug)Notes
The same pattern works in
exec_azure_discover_rankwhich also uses while/case, so the issue may be specific to script file execution context (the failing test writes the script to VFS and executes it as a file, while the passing test also does this but has a different script structure).