-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
OSH: Incompatible behavior of eval "sed -n \"\$script\""
#1449
Comments
eval "sed -n \"\$script\""
eval "sed -n \"\$script\""
The \" is somehow getting lost with backtick command sub, but not $()
OK I reproduced this -- it's actually not an IFS bug as I initially suspected With But NOT with backticks. It appears it's somehow losing the I will look at this -- thanks for the report! |
Including arithmetic. This is bug #1449.
The Oil parsing model is smart enough to parse double quotes inside backticks inside double quotes: echo "x `echo "hi"`" Shells aren't, and use this syntax instead: echo "x `echo \"hi\"`" This is issue #1449.
OK just fixed this! Fundamental issue: The Oil parsing model is smart enough to parse double quotes inside
Shells aren't, and use this syntax instead:
|
You might be interested to know that as recently as May of 2021 there were still people who cared very much about Autoconf and related tooling continuing to support Solaris 10 (As far as I know, Solaris 10 is the sole surviving member of the set of proprietary Unixes that froze their (I have a plan to migrate most of autoconf's code over to |
Anyway, thanks for the quick fix! Can I just point out, though, that the code from my original message did not have " nested inside ` inside ". Instead it had two levels of " quotation inside backticks. Your test case appears only to test " inside ` inside ". So I'd like to propose this additional test case. It passes with bash 5.2.15(1)-release and mksh 'MIRBSD KSH R59 2022/12/01', but the last two subtests fail with osh 0.13.1.
|
Run like this: test/gold.sh test-autoconf-backtick And then see _tmp/shebang.txt and _tmp/osh.txt. (This reminds me the test/gold.sh harness is a little wonky)
OK, all of that works at HEAD now: Run like this:
And then see _tmp/shebang.txt and _tmp/osh.txt. (This reminds me the Normally those kinds of tests would go in the It just runs scripts with the shebang line and OSH, and compares the stdout and exit code |
Feel free to add more test cases! I can help with the mechanics of that on Zulip Tests are all published with each release: https://www.oilshell.org/release/0.13.1/test/spec.wwz/survey/osh.html https://www.oilshell.org/release/0.13.1/test/other.wwz/gold.txt Also I definitely dislike backticks, but we're resigned to deal with them as every other shell does ... :-P (It's possible there are still divergences, since our parsing model is different. We don't look for matching quotes first -- we parse everything up front in a single pass. OSH started out mostly as a parsing experiment) I've been through a few iterations of "concede to reality" so it's OK :) |
Released last week -- https://www.oilshell.org/release/0.14.0/ I would be very interested in other bugs from autoconf! I have a plan for #1450 , but it would be nice to get a bunch of bugs at once How long do the auto test suites take to run? |
Autoconf uses a construct like
at one point in its generated
config.status
files. With both bash and dash, the effect of theeval
is to word-split the expansion ofsedinputs
but not word-split the expansion ofsedscript
. (It's not obvious to me why theeval
is necessary here, but this is the code used in the wild for many years now.)With osh 0.13.1, on the other hand, the expansion of
sedscript
is word-split, which causes sed to throw an error because its first command-line argument is not a complete sed script by itself.I don't know what, if anything, POSIX specifies here, but it seems to me that the bash/dash behavior is what a human would expect.
Complete reproducer script is attached. With bash or dash, the output is
ok
and exit code 0. With osh the output isand exit code 1.
improper-word-splitting-bug.sh.gz
The text was updated successfully, but these errors were encountered: