-
Notifications
You must be signed in to change notification settings - Fork 2
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
src/binutils-config: fix shellcheck warnings #3
base: master
Are you sure you want to change the base?
Conversation
Ideally the commit message body would include the warnings fixed. |
src/binutils-config
Outdated
"${EROOT}"/usr/libexec/gcc/${TARGET}/${x} | ||
"${EROOT}"/usr/bin/"${TARGET}"-"${x}" | ||
"${EROOT}"/usr/{${HOST}/,}"${TARGET}"/bin/"${x}" | ||
"${EROOT}"/usr/libexec/gcc/"${TARGET}"/"${x}" |
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.
Eyebleed city :( if you're quoting nearly an entire string, don't stop quoting just for the staticky-ness of a literal forward slash.
58f57d4
to
e68cdb8
Compare
src/binutils-config
Outdated
@@ -281,7 +283,7 @@ switch_profile() { | |||
# | |||
# Regen env.d if need/can be | |||
# | |||
if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then | |||
if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == "${HOST}" ]] ; 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.
If we're going to touch the line, we should combine the conditionals.
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 maybe don't really need to touch the line at all, since [[ explicitly defines variable quoting as unnecessary for the purpose of performing field splitting and filename expansion.
There is still a semantic difference -- a wildcard in ${HOST} will be treated as a wildcard-match (and other forms of pattern matching, including extglob) against the value of ${TARGET} -- but that could be called a feature. :)
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 think it's better to quote it due to ${HOST} being set to a string and if you want globbing, then it would be better to set it at RHS in test and not inside ${HOST}. Hopefully I understood you correctly.
src/binutils-config
Outdated
EROOT="${ROOT%/}${EPREFIX}/" | ||
export PORTAGE_CONFIGROOT="${EROOT}" | ||
|
||
cd "${BROOT}/" | ||
cd "${BROOT}/" || die "Could not cd into $BROOT" |
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.
Gentoo style is:
cd "${BROOT}/" || die "Could not cd into $BROOT" | |
cd "${BROOT}/" || die "Could not cd into ${BROOT}" |
Fixed warnings: src/binutils-config:129:21: warning: Quote the right-hand side of != in [[ ]] to prevent glob matching. [SC2053] [...] src/binutils-config:179:22: warning: Quote the right-hand side of == in [[ ]] to prevent glob matching. [SC2053] [...] src/binutils-config:61:7: note: Double quote to prevent globbing and word splitting. [SC2086] [...] src/binutils-config:18:1: warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164] src/binutils-config:323:23: warning: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206] [...] src/binutils-config:9:3: note: This default assignment may cause DoS due to globbing. Quote it. [SC2223] [...] src/binutils-config:306:28: note: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt . [SC2231] Disabled warnings: src/binutils-config:24:8: warning: ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090] [...] Signed-off-by: Allen-Kristjan Päll <[email protected]>
e68cdb8
to
e089c4b
Compare
No description provided.