wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
307 stars 25 forks source link

Consider role of '=' #40

Closed wryun closed 2 years ago

wryun commented 2 years ago

My main frustration with using es as an interactive shell is having to handle GNU style long arguments, as '=' is part of es syntax wherever it occurs in a line. i.e.

ls --color=always

will generate a syntax error. You can get around this with quotes or escapes:

ls --color\=always
ls --color'='always

But it's annoying, and means you can't copy/paste examples designed for other shells.

xs addressed this by replacing '=' with ':=', which is a good solution but drops backwards compatibilty and similarity with other shells.

I'm wondering if there's an easy way to make both uses of '=' work, since a normal usage of a long argument reliably results in a syntax error (as the LHS isn't valid).

memreflect commented 2 years ago

I think I've got it working. The most problematic part was understanding how redirection was represented in the tree and fixing it after rewriting the simple production broke redirection. I couldn't find a way around such a modification unfortunately. The tokenizer had to be modified slightly to insert carets, else foo = a=b would result in foo having 3 args; foo = a^=^b is how it will appear when using es -x.

memreflect/es-shell@45628a4b

wryun commented 2 years ago

Awesome! Tricky, but not too many changes at least. Would you like to raise a PR?