-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Use awk for reliable path stripping #1360
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
Conversation
This works with paths which contains regex meta characters.
Are those characters even valid in a PATH? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests that would have failed without your change?
Also, what is paste
? Is it part of POSIX?
According to SUS, there seems to be no restriction in PATH other than
Yes, I will. |
A new test was added. awk -v NVM_DIR="$(echo ${NVM_DIR} | sed -e 's/\\/\\\\/g')" -v RS=: ' but I am not sure this should be included. |
If it's legal in |
00c8c95
to
c65569c
Compare
Is this PR still valid? |
@umireon yep! there's an unrelated test failure; i'll rebase this again after fixing it. |
c65569c
to
783cc36
Compare
I don't remember this PR much. I'm surprised that this PR is still valid🤣 It was 5 years ago! |
life comes at you fast :-p sorry it took me so long to get back to it. |
|
783cc36
to
53f9ba8
Compare
The quotation trick is to avoid alias, the same as backslash trick.
This is for functions, not for built-ins. At that time, I misunderstood something. |
ah thanks, i never knew about the quotation trick, but since we use |
For example, |
indeed, i don't protect against that for anything that clearly belongs to nvm :-) |
Maybe |
There are too many possibilities in sourced shell scripts😭 |
yeah true :-) if someone has aliased |
I learned how I use the I'm not sure the awk command never fails. |
If tests are passing, we'll ship it, and if it fails, we'll get bug reports. |
There are some complicated awk scripts so there seem to be practices about awk in this project, thus it's OK. |
When I created this PR, nvm only has simple awk scripts as far as I remember, but I worry too much for now. Dismiss my comments. |
I think |
nvm_strip_path()
will fail ifNVM_DIR
contains meta characters such as#*.^$[]\
.awk
is capable to solve this problem.