-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ function install_packages() | |
run $sudo pkg install -y "$@" || return $? | ||
;; | ||
brew) | ||
local brew_owner="$(/usr/bin/stat -f %Su "$(command -v brew)")" | ||
local brew_owner= | ||
brew_owner="$(/usr/bin/stat -f %Su "$(command -v brew)")" | ||
local brew_sudo="" | ||
|
||
if [[ "$brew_owner" != "$(id -un)" ]]; then | ||
|
@@ -40,7 +41,10 @@ function install_packages() | |
run $brew_sudo brew upgrade "$@" || return $? | ||
;; | ||
pacman) | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, I forgot I can check using the archlinux docker image. |
||
done < <(pacman -T "$@") | ||
|
||
if (( ${#missing_pkgs[@]} > 0 )); then | ||
run $sudo pacman -S "${missing_pkgs[@]}" || return $? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Mine is 0.8.0 :D |
||
fi | ||
done < "$file" | ||
} | ||
|
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 thedependencies.txt
file and return theapt: pkg1 pkg2 ...
line that matches the"$package_manager"
, but without theapt:
prefix. It is then implicitly splatted into an Array of individual package names. Reading each line would causeruby_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