Skip to content

Commit

Permalink
[spec/assign] Test cases for dynamic and aliased assignment.
Browse files Browse the repository at this point in the history
Related to #392, #236.
  • Loading branch information
Andy Chu committed Jul 8, 2019
1 parent 86e702f commit 84467e7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
60 changes: 60 additions & 0 deletions spec/assign.test.sh
Expand Up @@ -409,3 +409,63 @@ x=local
- operator = global
:- operator = global
## END

#### static assignment doesn't split
words='a b c'
export ex=$words
glo=$words
readonly ro=$words
argv.py "$ex" "$glo" "$ro"

## STDOUT:
['a b c', 'a b c', 'a b c']
## END
## BUG dash STDOUT:
['a', 'a b c', 'a']
## END


#### aliased assignment doesn't split
shopt -s expand_aliases || true
words='a b c'
alias e=export
alias r=readonly
e ex=$words
r ro=$words
argv.py "$ex" "$ro"
## BUG dash STDOUT:
['a', 'a']
## END
## STDOUT:
['a b c', 'a b c']
## END


#### assignment using dynamic keyword splits
words='a b c'
e=export
r=readonly
$e ex=$words
$r ro=$words
argv.py "$ex" "$ro"
## STDOUT:
['a', 'a']
## END

# zsh is smart?? How does it do this?
## BUG zsh STDOUT:
['a b c', 'a b c']
## END

#### assignment using dynamic var names doesn't split
words='a b c'
arg_ex=ex=$words
arg_ro=ro=$words

export "$arg_ex"
readonly "$arg_ro"

argv.py "$ex" "$ro"
## STDOUT:
['a b c', 'a b c']
## END
2 changes: 1 addition & 1 deletion test/spec.sh
Expand Up @@ -274,7 +274,7 @@ word-eval() {

# These cases apply to many shells.
assign() {
sh-spec spec/assign.test.sh --osh-failures-allowed 1 \
sh-spec spec/assign.test.sh --osh-failures-allowed 5 \
${REF_SHELLS[@]} $ZSH $OSH_LIST "$@"
}

Expand Down

0 comments on commit 84467e7

Please sign in to comment.