Skip to content
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

[spec] Upgrade var-op-test from bash 4 to bash 5 #2211

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions spec/var-op-test.test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## compare_shells: bash-4.4 dash mksh zsh
## compare_shells: bash dash mksh zsh

#### Lazy Evaluation of Alternative
i=0
Expand Down Expand Up @@ -47,10 +47,14 @@ argv.py "X${unset=x$@x}X" # OSH is the same here
['Xx1 2 3 4xX']
['Xx1 2 3 4xX']
## END
## BUG bash STDOUT:
['Xx1', '2', '3', '4xX']
['Xx1 2 3 4xX']
## END

# Bash 4.2..4.4 had a bug. This was fixed in Bash 5.0.
#
# ## BUG bash STDOUT:
# ['Xx1', '2', '3', '4xX']
# ['Xx1 2 3 4xX']
# ## END

## OK osh STDOUT:
['Xx1 2', '3 4xX']
['Xx1 2 3 4xX']
Expand Down Expand Up @@ -101,7 +105,7 @@ argv.py "${with_icc+set}" = set
## STDOUT:
['', '=', 'set']
## END

#### ${s+foo} and ${s:+foo} when set -u
set -u
v=v
Expand Down Expand Up @@ -193,21 +197,6 @@ echo '+:' /"${array[@]:+foo}"/
echo


## STDOUT:
+ //
+: //

+ //
+: //

+ /foo/
+: /foo/

+ /foo/
+: /foo/

## END

## BUG mksh STDOUT:
+ //
+: //
Expand All @@ -223,6 +212,25 @@ echo

## END

# Bash 2.0..4.4 has a bug that "${a[@]:-xxx}" produces an empty string. It
# seemed to consider a[@] and a[*] are non-empty when there is at least one
# element even if the element is empty. This was fixed in Bash 5.0.
#
# ## BUG bash STDOUT:
# + //
# +: //
#
# + //
# +: //
#
# + /foo/
# +: /foo/
#
# + /foo/
# +: /foo/
#
# ## END

## BUG zsh STDOUT:
+ //
+: //
Expand Down Expand Up @@ -272,14 +280,14 @@ argv.py ${!hooksSlice+"${!hooksSlice}"}
['42']
## END

# Bash 4.4 has a bug that ${!undef-} is successfully generate an empty word.

## BUG bash STDOUT:
[]
[]
[]
['42']
## END
# Bash 4.4 has a bug that ${!undef-} successfully generates an empty word.
#
# ## BUG bash STDOUT:
# []
# []
# []
# ['42']
# ## END

## OK dash/mksh/zsh STDOUT:
## END
Expand Down Expand Up @@ -468,7 +476,7 @@ x
hello=x
hello=x
## END

#### array ${arr[0]=x}
arr=()
echo ${#arr[@]}
Expand Down Expand Up @@ -522,6 +530,8 @@ z
`
\
## END
# Note: this line terminates the quoting by ` not to confuse the text editor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this! that has bugged me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, though it is still a hack.



#### "\e" as arg
echo "${undef-\e}"
Expand All @@ -530,4 +540,3 @@ echo "${undef-\e}"
## END
## BUG zsh/mksh stdout-repr: '\x1b\n'
## BUG yash stdout: e