-
-
Notifications
You must be signed in to change notification settings - Fork 256
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 Shellcheck violations #443
base: master
Are you sure you want to change the base?
Conversation
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.
Spotted a few things. We may want to disable a few more of the ShellCheck rules, since they might not correctly be matching the code.
@@ -12,7 +12,7 @@ function fetch() | |||
|
|||
while IFS="" read -r line; do | |||
if [[ "$line" == "$key:"* ]]; then | |||
echo "${line##$key:*([[:space:]])}" | |||
echo "${line##"$key":*([[:space:]])}" |
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.
Are quotes really needed within bash variable substitutions?
var1="foo bar"
var2="foo bar baz"
echo "${var2#$var1 }"
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 don't think so, but shellcheck disagrees :D
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.
Wait, which version of ShellCheck are you using? I'm on 0.7.2, which might be older than your version, which might explain why I'm not seeing those warnings?
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.
Mine is 0.8.0 :D
ruby_dependencies=() | ||
while IFS='' read -r line; do | ||
ruby_dependencies+=("$line") | ||
done < <(fetch "$ruby/$file" "$package_manager" || return $?) |
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 actually need the implicit shell-splitting here. fetch "$ruby/$file" "$package_manager"
will read the dependencies.txt
file and return the apt: pkg1 pkg2 ...
line that matches the "$package_manager"
, but without the apt:
prefix. It is then implicitly splatted into an Array of individual package names. Reading each line would cause ruby_dependencies
to become a singleton Array that contains the whole line (ex: ("pkg1 pkg2 pkg3")
).
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.
Hmm, agree. I just followed (blindly) what Shellcheck WIKI was proposing :D
local missing_pkgs=($(pacman -T "$@")) | ||
local missing_pkgs=() | ||
while IFS='' read -r line; do | ||
missing_pkgs+=("$line") |
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 not a Arch user so I can't verify this, can you double check if pacman -T
outputs the missing packages one per-line or a single-line with the package names separated by spaces?
https://archlinux.org/pacman/pacman.8.html
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 have Arch installed, either. I'm just maintaining Gentoo ebuild in ::guru overlay, and currently I simply disable make check
:D
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.
Wait, I forgot I can check using the archlinux docker image.
Looking at some of the ShellCheck errors, I think
When you put a command inside of |
I'm fine if those checks will be disabled (globally or locally via comments). Just went the lazy approach by doing what SC proposes and making sure tests pass after that on my machine :D |
Resolves: #442