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

History expansion overrides indirect expansion #710

Open
Crestwave opened this issue Apr 16, 2020 · 3 comments
Open

History expansion overrides indirect expansion #710

Crestwave opened this issue Apr 16, 2020 · 3 comments

Comments

@Crestwave
Copy link
Contributor

Found this while testing for #697

osh$ foo=bar
osh$ set foo
osh$ echo "${!1}"
! echo "${foo=bar}"
bar
$ foo=bar
$ set foo
$ echo "${!1}"
bar
@andychu
Copy link
Contributor

andychu commented Apr 16, 2020

Ah OK good catch.

I recall that bash's history lexer has a very specific special case for stuff like this, including:

  • the ! operator inside [[ ]]
  • extended globs like !(foo|bar)
  • single quoted strings (but not double quoted strings, which a lot of people are surprised/annoyed by)

I think this is probably possible to fix ...

  • Consider expanding history as part of the parser #452 is on my mind but it has some downsides. That would make history a "proper" part of the language and not this weird lexer on top, which is what bash does. I guess the reason I chose to do it bash's way is because history is only on interactively.

@andychu
Copy link
Contributor

andychu commented Aug 12, 2021

Not directly related to this issue but lots of users have reported confusiong over history expansion rules. From Tom Van Vleck:

 Exclamation points,
for example. All I know for sure is that I have to escape
them. Sometimes.  And that they mean several different things.
e.g. when I want to refer to a process ID, how many times do I escape it?

I remember someone else saying they had histexpand off because it expands within double quotes.

@andychu
Copy link
Contributor

andychu commented Jan 6, 2022

Just ran into this one while testing out another bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants