-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[word_eval] Implement 'shopt -s compat_array'. #728
Changes from all commits
9fc20e7
c2365f5
bf9f332
6704770
b1a16c2
4662002
b311fb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,3 +576,37 @@ v=tempenv1 f4_unset global,tempenv1 | |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 3) | ||
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 4) | ||
## END | ||
|
||
#### [compat_array] ${arr} is ${arr[0]} | ||
case ${SH##*/} in (dash|ash) exit 1;; esac # dash/ash does not have arrays | ||
case ${SH##*/} in (osh) shopt -s compat_array;; esac | ||
case ${SH##*/} in (zsh) setopt KSH_ARRAYS;; esac | ||
arr=(foo bar baz) | ||
echo "$arr" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should also test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the test for |
||
## stdout: foo | ||
|
||
## N-I dash/ash status: 1 | ||
## N-I dash/ash stdout-json: "" | ||
|
||
## OK yash stdout: foo bar baz | ||
|
||
#### [compat_array] scalar access to arrays | ||
case ${SH##*/} in | ||
(dash|ash) exit 1;; # dash/ash does not have arrays | ||
(osh) shopt -s compat_array;; | ||
(zsh) setopt KSH_ARRAYS;; | ||
esac | ||
|
||
a=(1 0 0) | ||
: $(( a++ )) | ||
argv.py "${a[@]}" | ||
## stdout: ['2', '0', '0'] | ||
|
||
## N-I dash/ash status: 1 | ||
## N-I dash/ash stdout-json: "" | ||
|
||
## OK yash STDOUT: | ||
# yash does not support scalar access. Instead, it replaces the array | ||
# with a scalar. | ||
['1'] | ||
## END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this part be made obsolete if we made BASH_LINENO etc. immutable?
I guess that would make Oil technically incompatible, but I've been thinking about that. Also it makes sense to tighten up things like
PATH=(a b c)
andHOME=(a b c)
(they shouldn't be arrays)This doesn't have to be done in this commit; I'm just curious / brainstorming the semantics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you have already written in another comment, this change also affects the other mutable variables when
shopt -s compat_array
is set.