oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.82k stars 154 forks source link

Consider expanding history as part of the parser #452

Open andychu opened 5 years ago

andychu commented 5 years ago

This isn't the way bash does it, but #451 made me think that this might be a good idea. (We copied bash's strategy of doing an entirely separate preprocessing/lexing phase.)

And I think it's pretty easily possible.

Comments aren't purely lexical because of echo x#notcomment and echo 'x'#notcomment, etc.

notes: in bash, history is expanded in double quotes, NOT in single quotes, and NOT in comments.

We can easily implement that rule. (Although honestly I don't see a use case for it being expanded in double quotes...)

$ echo hi
hi
$ echo "!!"
echo "echo hi"
echo hi
andychu commented 5 years ago

A few people mentioned here that they don't like that history is expanded within double quotes like "!!", which I agree with. If we do it as part of the parser it would fix that problem.

https://lobste.rs/s/l2fk5f/seven_god_like_bash_history_shortcuts_you

andychu commented 5 years ago

Also relevant to history:

zsh has hist_verify, which shows the result of history replacements/substitutions, and makes you hit enter again before execution. Seems like a nice middle ground between “blind” and TUI.

andychu commented 9 months ago

Zulip thread - https://oilshell.zulipchat.com/#narrow/stream/325160-oil-discuss-public/topic/!!.20history.20expansion.20.28Second.20Grant.20Planning.29

Surprised users - https://twitter.com/burntsushi5/status/1734223796914028647