Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion share/ruby-install/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function load_dependencies_from()
{
local file="$1"

ruby_dependencies=($(fetch "$ruby/$file" "$package_manager" || return $?))
ruby_dependencies=()
while IFS='' read -r line; do
ruby_dependencies+=("$line")
done < <(fetch "$ruby/$file" "$package_manager" || return $?)
Copy link
Owner

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")).

Copy link
Author

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

}

#
Expand Down
5 changes: 4 additions & 1 deletion share/ruby-install/package_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,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")
Copy link
Owner

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

Copy link
Author

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

Copy link
Owner

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.

done < <(pacman -T "$@")

if (( ${#missing_pkgs[@]} > 0 )); then
run $sudo pacman -S "${missing_pkgs[@]}" || return $?
Expand Down