-
-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
Bashly Version
Latest Ruby Gem
Description
The generated parse_requirements function declares the variable key without the local keyword, causing it to pollute the global scope. This leads to unexpected behavior when user scripts use a variable named key and then call another command via run().
Contents of bashly.yml
Reproduction Steps
- Create a command script that uses a variable named
key:
# src/my_command.sh
key="my_value"
echo "Before run: key=$key"
run other_command
echo "After run: key=$key" # key is now overwritten- Generate the script with
bashly generate - Run the command and observe that the
keyvariable is overwritten after callingrun()
Actual Behavior
In lib/bashly/views/command/parse_requirements_while.gtx:4, the variable key is declared without local:
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" inThis should be:
while [[ $# -gt 0 ]]; do
local key="$1"
case "$key" inExpected Behavior
The key variable should be local to the parse_requirements function and not interfere with user-defined variables in command scripts.
Environment
Bashly version: 1.3.3
Bash version: 5.1.16
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working