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
test: reshim of plugins installed by path #1287
Conversation
Can you add a test case for regression testing? |
Hi, I add a test case for testing, could you please review the change? |
lib/commands/reshim.bash
Outdated
@@ -90,7 +90,7 @@ write_shim_script() { | |||
|
|||
if [ -f "$shim_path" ]; then | |||
if ! grep -x "# asdf-plugin: ${plugin_name} ${version}" "$shim_path" >/dev/null; then | |||
sed -i.bak -e "s/exec /# asdf-plugin: ${plugin_name} ${version}\\"$'\n''exec /' "$shim_path" | |||
sed -i.bak -e "s|exec |# asdf-plugin: ${plugin_name} ${version}\\"$'\n''exec |' "$shim_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.
The |
pipe character is permitted in file names so this fix may not be sufficient for all cases.
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.
don't allowed filename special character:
- Windows (FAT32, NTFS): Any Unicode except
NUL
,\
,/
,:,
*
,?
,"
,<
,>
,|
. Also, no space character at the start or end, and no period in the end. - Mac(HFS, HFS+): Any valid Unicode except
:
or/
- Linux(ext[2-4]): Any byte except
NUL
or/
so I think |
may not be the best character in this scenario, but I can't find the better one~, and most of us won't use |
as a part of filename
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.
We started validating plugin names in #1010, perhaps we should be validating dir names before we create/modify them in asdf so we can be more confident about which special char we use here.
I also think once we decide which to use we should use it consistently across the project (a follow up PR seems best)
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.
What if we used Bash substring replacement for this? The Bash expression can be parameterized. (see https://tldp.org/LDP/abs/html/string-manipulation.html and scroll down to the Substring Replacement header).
Something like this (I haven't had a chance to test it):
line=$(...)
match='exec '
replacement="# asdf-plugin: ${plugin_name} ${version}\\"$'\n''exec "
updated_line=${line/$match/$repl}
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.
@Stratus3D @jthegedus
Hi guys:
Maybe I have found a better way to solve this problem.
Insert a new line before the last line rather than regex and replace the previous line with multi-lines.
the code below:
sed -i.bak -e '$i\'$'\n'"# asdf-plugin: ${plugin_name} ${version}" "$shim_path"
$i\'$'\n'
means inserting a new line before the last line. this flag works on both Linux and macOS. so we insert the plugin info to the new line without regex.
We could avoid the conflict problem with sed delimiter character by using this approach.
could you guys review this change? thx.
can anyone review the new change? |
@alexezio please review the failed status checks |
@jthegedus |
It seems like all unit-test are passed, so could this pr be approved? |
@alexezio Sorry for my absence and delay here. Can you address the Shellcheck issue?
|
@jthegedus hi, sorry for my absence. I check the shellcheck error, and I think that is not a issue. |
From @dylan-chong from - #1311 (comment)
Let's:
and get this test case in and close out this PR. |
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.
Updated this to just be a new test case as per #1287 (comment)
Thanks 🙇
Thanks for writing the test for this @alexezio ! And thanks for getting this merged @jthegedus ! |
Summary
change sed delimiter character from
/
to|
to prevent reshim local path error(sed delimiter character conflict)
Fixes: #1286
Other Information
maybe we could use a better delimiter character for this scenario?