-
-
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
Incorrect behavior of $@ and $* when IFS='' #627
Comments
Wow interesting, I'm not sure why this is yet, I verified that bash/mksh/zsh/busybox ash agree. However dash 0.5.8 agrees with osh. |
Dash 0.5.10 agrees with Bash, so does whatever version of dash this is My sha1sum is |
|
Addresses issue #627. Unrelated: tweak doc.
OK thanks a lot! That helps. I verified this bug through the spec tests. I think it should be pretty easy to fix but I'm not quite sure. I think test case 8 here is related https://www.oilshell.org/release/0.8.pre2/test/spec.wwz/assoc.html |
It is similar, but I don't think it's related. Unquoted $ set -- a 'b c'
$ printf '[%s]\n' "$*"
[a b c] # osh prints "[a b c]" |
Generalizing the behavior with an arbitrary string concatenated before or after the (Suppose
EDIT: I just checked osh, and it does normal word splitting correctly, unless it crashes. One sec, I have a new issue :P |
FWIW these are the test cases for splitting, although there is a TODO at the end to test more of https://www.oilshell.org/release/0.8.pre2/test/spec.wwz/word-split.html Honestly it surprised me that all shells agree so thoroughly on word splitting, beyond what POSIX seems to specify. (except dash 0.5.8 I guess) I was able to find divergences in basically all shell features, but somehow with word splitting everyone agrees, even though it's quite a complicated algorithm ... (And I know how to fix the |
This seems to be POSIX, though? Or are you just referring to the other tests? Interestingly, though, I found this page with the same results as OSH but I don't really know what it's for. set "abc" "def ghi" "jkl"
...
IFS=" # null
...
printf '%s\n' ${var-$*}
abcdef ghijkl The actual specification, though, says (emphasis mine):
|
#331 also mentions an empty IFS difference |
In bash or dash, this prints:
In osh, this prints:
The same applies to bash arrays under
${a[@]}
and${a[*]}
.In general, an array without quotes should not be subject to joining. First substitute all words, then split them on IFS. (Exceptions:
[[
andcase
)The text was updated successfully, but these errors were encountered: