-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
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.
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.
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 !
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 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 |
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.
Use \w
for pwd
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 |
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.
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.txt
and formatted it usinglint_clean_files.sh
.