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
Replace ~ only works at beginning of a word #1410
Comments
It looks like bash will expand ~ after an = sign, but not after a letter. Anyone care to track down what the actual rules are? |
The exact rules are undocumented, but I assume the rules look like (regex) |
testing bashhttps://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Tilde-Expansion
Yikes, the
More precisely, it really seems to check the left side looks like a variable name:
So, this really looks like a heuristic to match variable assignments, but doesn't actually check the position in the command line, so also works for Bash in posix modedidn't test as fully, seems to behave similarly, except this really weird corner:
[tested on GNUa «bash», versio 5.0.7(1)-release (x86_64-redhat-linux-gnu)] Does POSIX have an opinion?https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_01
Sounds pretty much like bash. The weird corner in bash posix mode actually sounds like a bug?
|
zshhttps://unix.stackexchange.com/questions/373519/expansion-of-tilde-in-zsh
The practical difference is:
However, you still need the
So I stand by my recommendation for fish to always expand after |
Great research - thank you! I certainly think starting with expanding after |
I also encountered the I realize there is no fix at present, but is there a workaround? |
I still would like to fix this, but as a workaround you can use |
It seems like the
~
only gets replaced with the home directory when it is at the beginning of a word. Is that intentional?I tried this in fish:
And the same thing in bash:
But then in fish this works as expected:
The text was updated successfully, but these errors were encountered: