Fix home dir substitution#1974
Conversation
See the discussions in 953e422#commitcomment-58148656 . Tested with bash 5.1 and bash 3.2
The tilde should not have been escaped, and in fact I did not have it escaped in my main branch, but the PR I submitted did have it escaped and...now it shows up in the prompt line for all the PowerLine themes... oops.
davidpfarrell
left a comment
There was a problem hiding this comment.
I'm approving this since it does everything I asked :)
However there are at least 6 other occurrence of this idea in the repository that will also need attention at some point.
Thanks for taking the time @zou000 !
gaelicWizard
left a comment
There was a problem hiding this comment.
The quotes are necessary to avoid word splitting and will be rejected by the automated checks
|
Is there a reason we're not using |
Can you elaborate? I tested with a directory name with space in it and it worked as expected. ❯mkdir t\ t
❯cd t\ t
❯cwd=${PWD/$HOME/\~}
❯echo $cwd
~/t t |
Hmm... no idea, I change to use |
Soo the quotes do not appear to be necessary in the context on an assignment: test.sh #!/usr/bin/env bash
# assign with no quotes
wd=${PWD/#$HOME/\~}
echo "${wd}"
# direct usage with no quotes
echo ${PWD/#$HOME/\~}shellcheck $ shellcheck test.sh
In test.sh line 8:
echo ${PWD/#$HOME/\~}
^--------------^ SC2086: Double quote to prevent globbing and word splitting.Notice that the assignment did not generate a warning. /Side Note : @gaelicWizard I've been meaning to tell you that I came across you in the wild: I was researching an issue for my work laptop (i.e not related to bash-it at all) and found your posts there. I just thought it was cool and wanted to mention it ... |
The Bash It repo is set up to run |
gaelicWizard
left a comment
There was a problem hiding this comment.
Honestly, I feel kinda silly that I "fixed" the original by making it worse when the correct fix was to stop being clever entirely and just use the regular prompt string escapes 🤪
Thanks for fixing my "fix"!! ♥
I was way more of a prick back then, so feel free to look the other way... 😉 |
|
well done @zou000, and thanks for the review @gaelicWizard and @davidpfarrell 😄 |
See the discussions in 953e422#commitcomment-58148656 . Tested with bash 5.1 and bash 3.2
Description
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
clean_files.txtand formatted it usinglint_clean_files.sh.