-
-
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
disallowing redirects on control flow too strict by default (Run ble.sh) #620
Comments
Ah geez, OK I think bash might spew on I disallowed that because it seems nonsensical -- why would you want to redirect the output of But if bash prints some spew to stderr, that's valid. So I might need to introduce an option Thanks for the report! |
Bash does print error messages when $ bash -c return
bash: line 0: return: can only `return' from a function or sourced script The line |
Yes, I remember seeing that, there is a test case for it somewhere. Oil follows other shells and allows So unfortunately Oil may have to provide compatibility with the bash workarounds that aren't necessary in Oil ... |
I assume the following sentence in the article "Why Create a New Unix Shell?" is still valid for the current Oil. (Does the "shell script" in the following sentence include (some subset of) Bash scripts?)
I don't think I have also played with return is builtin in POSIX/bashOil seems to handle Even though, Oil reports $ bin/osh -c 'type -t return'
builtin Another interesting observation is that $ bash -c 'function return { echo hello; }; return; echo world'
hello
world
$ bin/osh -c 'function return { echo hello; }; return; echo world'
$ Another builtin builtin returnAlthough $ bin/osh -c 'builtin echo hello'
hello
$ bin/osh -c 'builtin return'
builtin return
^~~~~~
[ -c flag ]:1: 'return' isn't a shell builtin
$ exit is also builtinAlso I would like to point out that Bash can output error messages even for |
Yes that's documented here: I guess I should change A few bugs with this label here: https://github.com/oilshell/oil/labels/divergence If you see anything else, let me know! Also related: https://github.com/oilshell/oil/wiki/What-Is-Expected-to-Run-Under-OSH I haven't looked at ble.sh yet ... 24K lines is very big :) But Oil does run thousands of lines of unmodified shell. Sometimes small patches are required. A goal is to allow running under both bash and OSH, after slight patches. That is, you might have to modify a few things, but it should run under both interpreters. If that's awkward for any reason, I'm interested. But yes as mentioned interactive scripts are more likely to run into unimplemented features ( |
Thank you for the pointers! Actually |
Wow I'm looking through the I tried this command to parse all shell files in ble:
I think it may have found a bug?
That doesn't appear to be valid bash syntax, bash will complain too:
The difference is that Oil statically parses arithmetic, whereas in bash does it at runtime (which is also documented in the doc, and I wrote about it on the blog) |
Oil doesn't like this part:
maybe that can be worked around with The other errors are because Oil doesn't like assignments where the var name is dynamic:
That could possibly be relaxed since Oil does dynamic assignment for |
Anyway I will try it out more later! Looks very cool though. I'm surprised you can do it all in bash :) |
Thank you very much! This is a shameful bug... It should have been
Yes. Both I think I need to check |
I'm surprised there's only 1 bug in 30K+ lines of shell! :) I think this is one of the biggest shell programs I've ever seen, and I've looked for big ones for a number of years, e.g. https://www.oilshell.org/release/0.8.pre2/test/wild.wwz/ (I guess there are a lot of comments though.) BTW this parsing feature was one of the first things I wrote about in the blog. However back then Oil probably couldn't understand ble.sh; now it appears to do a decent job. http://www.oilshell.org/blog/2016/10/13.html I added some failing test cases for dynamic assignment here inspired by ble.sh: It's not that big a change to support, but I'm not sure when/if I'll get to it. I still need to try out ble.sh to see how it works :) |
OK back to the original issue, I allowed |
Also I'm interested in any such differences that matter for In other words is there anything else to document here? |
Thank you. Oh, 24k was my mistake that I forgot to include ble.sh itself when running commands. It was 44k / 32k lines including / excluding comments. Actually I found another bug of ble.sh using By the way, I found several things in which Bash and Oil behaves differently. I'm not sure whether all of them are intended design of Oil or not but seems a little bit long to describe them here. Should I create independent Issues or can I discuss them here? |
Yes let's discuss in a new bug! The differences should be documented, or if there are unintended ones they can be fixed. (we also have a chat at https://oilshell.zulipchat.com/ , but Github is fine too) |
Thank you! I pushed fixes of ble.sh found by Overridable/protected builtins
ble.sh overrides the builtins for b in $(enable | awk '$0=$2'); do
echo "=== $b ==="
bin/osh -c "function $b { echo hello; }; $b"
done I found that, in addition to control flow keywords ( It is interesting to observe that one can override mapfile/readarrayBy the way, ble.sh uses the builtins |
OK I made a new issue for the builtin shadowing. Although I think some of it may relate to "special builtins" as defined by POSIX.
https://github.com/oilshell/oil/wiki/Shell-Programs-That-Run-Under-OSH |
https://github.com/akinomyoga/ble.sh
The following line is not supported by osh: https://github.com/akinomyoga/ble.sh/blob/58e1be46bea16acb487327f61d9cb44fd67651b8/ble.pp#L95
The text was updated successfully, but these errors were encountered: