Skip to content

Commit

Permalink
[spec/introspect] Stub out shopt -s compat_array and add failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Apr 23, 2020
1 parent eebb9b1 commit ee80ef0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/option_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ def _Init(opt_def):
# shopt options that aren't in any groups.
opt_def.Add('failglob') # not implemented.

# TODO: Rename eval_unsafe_arith
opt_def.Add('eval_unsafe_arith') # recursive parsing and evaluation (ble.sh)
opt_def.Add('parse_dynamic_arith') # dyanmic LHS
opt_def.Add('parse_dynamic_arith') # dynamic LHS
opt_def.Add('compat_array') # ${array} is ${array[0]}

# Two strict options that from bash's shopt
for name in ['nullglob', 'inherit_errexit']:
Expand Down
23 changes: 23 additions & 0 deletions spec/introspect.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,37 @@ ____
['11']
## END


#### ${FUNCNAME} with prefix/suffix operators (OSH regression)
shopt -s compat_array

check() {
argv.py "${#FUNCNAME}"
argv.py "${FUNCNAME::1}"
argv.py "${FUNCNAME:1}"
}
check
## STDOUT:
['5']
['c']
['heck']
## END

#### operators on FUNCNAME not allowed by default
check() {
argv.py "${FUNCNAME}"
argv.py "${#FUNCNAME}"
argv.py "${FUNCNAME::1}"
argv.py "${FUNCNAME:1}"
}
check
## status: 1
## STDOUT:
['check']
## END
## OK bash status: 0
## OK bash STDOUT:
['check']
['5']
['c']
['heck']
Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ special-vars() {
}

introspect() {
sh-spec spec/introspect.test.sh --no-cd-tmp \
sh-spec spec/introspect.test.sh --no-cd-tmp --osh-failures-allowed 1 \
$BASH $OSH_LIST "$@"
}

Expand Down

0 comments on commit ee80ef0

Please sign in to comment.