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

Issues when using empty aliases with certain builtins #299

Closed
Crestwave opened this issue May 7, 2019 · 4 comments
Closed

Issues when using empty aliases with certain builtins #299

Crestwave opened this issue May 7, 2019 · 4 comments

Comments

@Crestwave
Copy link
Contributor

Crestwave commented May 7, 2019

$ alias a=
$ a declare var=0 # Same result with local, but export works fine. This also fails when aliased to
   declare var=0
                 ^
[ expansion of alias 'a' ]:1: Invalid variable name ''
$ a (( var = 0 ))
  a (( var = 0 ))
    ^~
'/home/user/.config/oil/oshrc':13: Unexpected word while parsing command
line
$ a var=0
$ printf '%s\n' "$a"

$ a f() { :; }
  a f() { :; }
     ^
'/home/user/.config/oil/oshrc':16: Unexpected word while parsing command
line
$ a case a in a) : ;; esac
   case a in a
               ^
[ expansion of alias 'a' ]:1: Expected word type <Id_t Right_CasePat 94>, got <Id_t Word_Compound 199>
@andychu
Copy link
Contributor

andychu commented May 7, 2019

The inconsistency between export and declare/local will be fixed with #236 (dynamic assignments).

The other bugs are I guess because OSH has a different parsing/evaluation model of aliases. They seem somewhat similar to cases 33-34 here:

http://www.oilshell.org/release/0.6.pre18/test/spec.wwz/alias.html

where I have alias LEFT='{' and alias LEFT='(', which works in most shells but not OSH.

That is basically because of the design philosophy here:

http://www.oilshell.org/blog/2019/02/07.html

Are you using this for something? If not, I'm inclined to leave this as is, unless there it moves something here forward:

https://github.com/oilshell/oil/wiki/Shell-Programs-That-Run-Under-OSH

All the shell parsers I looked at are littered with special cases regarding aliases. In contrast, OSH uses the parser "from the outside", which is more understandable. It has a pretty clear evaluation model, whereas in most shells you have to enumerate all the special cases to know what it does.


Another case where this is true is a slight incompatibility with backticks, which somebody on help-bash@ is trying (and failing) to get an explanation of right now... OSH has a pretty compatible and explainable rule that runs virtualenv, but it disagrees on a corner case where other shells agree.

That is case #25 here:

http://www.oilshell.org/release/0.6.pre18/test/spec.wwz/command-sub.html

However shells stop agreeing on case #26 :)

andychu pushed a commit that referenced this issue May 7, 2019
@andychu
Copy link
Contributor

andychu commented May 7, 2019

I just committed a spec test that records this incompatibility. It's unfortunate that all shells do agree on this and OSH doesn't, but like I said, I'm going to put it low on the pile unless real world use cases show up.

I also started documenting some more of the known incompatibilities in doc/osh-manual.md.

@Crestwave
Copy link
Contributor Author

Are you using this for something? If not, I'm inclined to leave this as is, unless there it moves something here forward:

https://github.com/oilshell/oil/wiki/Shell-Programs-That-Run-Under-OSH

Nope; I found it while playing with https://github.com/rdebath/Brainfuck/blob/master/extras/bf2bash.sh, which is honestly quite horribly written/hacky in my opinion.

@andychu
Copy link
Contributor

andychu commented May 8, 2019

OK since I documented this incompatibility in the spec tests, I'm closing this... it may or may not come up again in the future :-/

@andychu andychu closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants