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

${!1:-foo} fails with no positional parameters instead of substituting for foo #697

Closed
Crestwave opened this issue Apr 7, 2020 · 4 comments

Comments

@Crestwave
Copy link
Contributor

Required for #679. This is pretty weird, though, as it fails if it is set to an empty string or with an unset variable; perhaps Neofetch should be patched instead.

$ echo "${!1:-foo}"
foo
osh$ echo "${!1:-foo}"
  echo "${!1:-foo}"
           ^
[ interactive ]:1: fatal: Bad indirect expansion: ''
@andychu
Copy link
Contributor

andychu commented Apr 7, 2020

Yeah I remember thinking about this case when implementing ${!ref} recently... it is possible to emulate bash but it seemed like it could also catch programming errors.

The issue is that '' is not a valid variable name, but bash has a "silent" default for that...

Let's look at the other stuff and circle back to this.

@Crestwave
Copy link
Contributor Author

Dylan has agreed to fix this on their end. I'll leave it up to you whether to close this issue or not

@andychu
Copy link
Contributor

andychu commented Jan 6, 2022

Hm this got fixed at some point

$ osh -c 'echo ${!1:-foo}'
foo

(although I think there is still a related bug with confusing it with history substitution in interactive shells)

@andychu andychu closed this as completed Jan 6, 2022
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