-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
ShellCheck v0.4.7 fixes #1684
ShellCheck v0.4.7 fixes #1684
Conversation
Until I can use the updated shellcheck locally, I'm not going to be comfortable landing this. |
@@ -53,7 +53,7 @@ nvm_command_info() { | |||
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4="" ;print }' | command sed -e 's/^\ *//g' -Ee "s/\`|'//g" ))" | |||
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is an alias for"; then | |||
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4=$5="" ;print }' | command sed 's/^\ *//g'))" | |||
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \/"; then | |||
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \\/"; then |
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.
is the intention here to grep for $COMMAND is \/
or $COMMAND is /
?
https://github.com/koalaman/shellcheck/wiki/SC1117 implies that it probably should have been $COMMAND is /
?
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.
$COMMAND is /
, the effect here is the same, it won't be $COMMAND is \/
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.
Doesn't \\
put a literal backslash into the text?
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 thought so but I don't think so now. From SC1117 wiki, looks like it's because we use "
not '
.
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.
ok, so '\n'
is correct, and "\\n"
is the double-quoted equivalent?
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.
Seems so!
nvm.sh
Outdated
@@ -645,16 +645,16 @@ nvm_print_formatted_alias() { | |||
DEST_FORMAT='%s' | |||
VERSION_FORMAT='%s' | |||
local NEWLINE | |||
NEWLINE="\n" | |||
NEWLINE="\\n" |
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.
This just doesn't seem right to me. The intention is to insert a literal newline; not to literally add a backslash and an n
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.
Yes, it's newline, that's the tricky point I think.
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.
\\n
isn't a newline tho :-/
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.
Really? I tested it with this code block and it looks fine:
export NEWLINE="\n"
command printf -- "${NEWLINE}"
unset NEWLINE
export NEWLINE="\\n"
command printf -- "${NEWLINE}"
unset NEWLINE
command printf -- "${NEWLINE}"
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 confused; does that mean \n
and \\n
are the same? Or is the former a literal newline, and the latter a literal \n
that the shell later turns into a newline?
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.
Yeah, I think they are the same as the wiki mentions, the old usage may be wrong, and just fallback as what we want, that's the reason why they output the same.
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.
so on this line; can it be replaced with '\n'
?
bash_completion
Outdated
@@ -10,7 +10,7 @@ __nvm_generate_completion() | |||
{ | |||
declare current_word | |||
current_word="${COMP_WORDS[COMP_CWORD]}" | |||
COMPREPLY=($(compgen -W "$1" -- "$current_word")) | |||
COMPREPLY=("$(compgen -W "$1" -- "$current_word")") |
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.
is not the intention to split the output here?
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.
My fault.
4fd4e8e
to
6632245
Compare
nvm.sh
Outdated
" \ | ||
-e "s#^\([^/]\{1,\}\)/\(.*\)\$#\2.\1#;" \ | ||
-e "s#^\\([^/]\\{1,\\}\\)/\\(.*\\)\$#\\2.\\1#;" \ |
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.
instead of making this line less readable, could it be single-quoted instead?
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 tested it and it seems wrong lol.
nvm.sh
Outdated
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \ | ||
| command sed " | ||
s#\(.*\)\.\([^\.]\{1,\}\)\$#\2-\1#; | ||
s#\\(.*\\)\\.\\([^\\.]\\{1,\\}\\)\$#\\2-\\1#; |
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.
same here
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.
This one combined with shell variable below, I'm not very sure how to deal with it lol
de43f24
to
6632245
Compare
6632245
to
d1fe2a9
Compare
nvm.sh
Outdated
if [ "_${DEFAULT}" = '_true' ]; then | ||
NEWLINE=" (default)\n" | ||
NEWLINE=" (default)\\n" |
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.
also can this be single-quoted, and then the double backslash removed?
nvm.sh
Outdated
fi | ||
local ARROW | ||
ARROW='->' | ||
if [ -z "${NVM_NO_COLORS}" ] && nvm_has_colors; then | ||
ARROW='\033[0;90m->\033[0m' | ||
if [ "_${DEFAULT}" = '_true' ]; then | ||
NEWLINE=" \033[0;37m(default)\033[0m\n" | ||
NEWLINE=" \\033[0;37m(default)\\033[0m\\n" |
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.
also can this be single-quoted, and then the double backslash removed?
nvm.sh
Outdated
@@ -1021,25 +1021,23 @@ nvm_ls() { | |||
PATTERN='v' | |||
SEARCH_PATTERN='.*' | |||
else | |||
SEARCH_PATTERN="$(echo "${PATTERN}" | command sed "s#\.#\\\.#g;")" | |||
SEARCH_PATTERN="$(echo "${PATTERN}" | command sed "s#\\.#\\\\.#g;")" |
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.
also here
d1fe2a9
to
2d2f643
Compare
Hope this one can be good, replaced those patterns without a variable to use the single quote now. |
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.
Thanks!
2d2f643
to
2a8a81d
Compare
Noticed that |
Tests passed! |
…fixes ShellCheck v0.4.7 fixes
ShellCheck v0.4.7 just released 6 hours ago and hopefully will be deployed on Travis CI soon.
This is the fix for SC2207 and SC1117