Merge pull request #336 from Stratus3D/fix-shellcheck-warnings

Fix shellcheck warnings.
This commit is contained in:
Trevor Brown 2018-06-16 15:29:24 -04:00 committed by GitHub
commit 5e494f28e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 17 deletions

View File

@ -25,9 +25,9 @@ install_command() {
}
get_concurrency() {
if which nproc > /dev/null 2>&1; then
if command -v nproc > /dev/null 2>&1; then
nproc
elif which sysctl > /dev/null 2>&1 && sysctl hw.ncpu > /dev/null 2>&1; then
elif command -v sysctl > /dev/null 2>&1 && sysctl hw.ncpu > /dev/null 2>&1; then
sysctl -n hw.ncpu
elif [ -f /proc/cpuinfo ]; then
grep -c processor /proc/cpuinfo

View File

@ -6,7 +6,7 @@ list_command() {
plugins_path=$(get_plugin_path)
if ls "$plugins_path" &> /dev/null; then
for plugin_path in $plugins_path/* ; do
for plugin_path in "$plugins_path"/* ; do
plugin_name=$(basename "$plugin_path")
echo "$plugin_name"
display_installed_versions "$plugin_name"
@ -32,4 +32,4 @@ display_installed_versions() {
display_error 'No versions installed'
exit 1
fi
}
}

View File

@ -8,12 +8,12 @@ plugin_list_all_command() {
plugins_local_path="$(get_plugin_path)"
if ls "$plugins_index_path" &> /dev/null; then
for index_plugin in $plugins_index_path/*; do
for index_plugin in "$plugins_index_path"/*; do
index_plugin_name=$(basename "$index_plugin")
source_url=$(get_plugin_source_url "$index_plugin_name")
installed_flag=""
for local_plugin in $plugins_local_path/*; do
for local_plugin in "$plugins_local_path"/*; do
local_plugin_name=$(basename "$local_plugin")
[[ "$index_plugin_name" == "$local_plugin_name" ]] && installed_flag="*"
done

View File

@ -2,14 +2,14 @@ plugin_list_command() {
local flag=$1
# 0 || 1 with flag
if [ $# -eq 0 ] || ([ $# -eq 1 ] && [ "$flag" == "--urls" ]); then
if [ $# -eq 0 ] || { [ $# -eq 1 ] && [ "$flag" = "--urls" ]; }; then
# valid command
local plugins_path
plugins_path=$(get_plugin_path)
if ls "$plugins_path" &> /dev/null; then
for plugin_path in $plugins_path/* ; do
for plugin_path in "$plugins_path"/* ; do
plugin_name=$(basename "$plugin_path")
if [ $# -eq 0 ]; then

View File

@ -1,7 +1,7 @@
plugin_push_command() {
local plugin_name=$1
if [ "$plugin_name" = "--all" ]; then
for dir in $(asdf_dir)/plugins/*; do
for dir in "$(asdf_dir)"/plugins/*; do
echo "Pushing $(basename "$dir")..."
(cd "$dir" && git push)
done

View File

@ -139,7 +139,7 @@ generate_shims_for_version() {
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
for bin_path in "${all_bin_paths[@]}"; do
for executable_file in $install_path/$bin_path/*; do
for executable_file in "$install_path/$bin_path"/*; do
# because just $executable_file gives absolute path; We don't want version hardcoded in shim
local executable_path_relative_to_install_path
executable_path_relative_to_install_path="$bin_path"/$(basename "$executable_file")
@ -238,7 +238,7 @@ remove_shims_for_version() {
IFS=' ' read -r -a all_bin_paths <<< "$space_separated_list_of_bin_paths"
for bin_path in "${all_bin_paths[@]}"; do
for executable_file in $install_path/$bin_path/*; do
for executable_file in "$install_path/$bin_path"/*; do
local executable_name
executable_name="$(basename "$executable_file")"
remove_shim_for_version "$plugin_name" "$executable_name" "$version"

View File

@ -214,7 +214,7 @@ get_executable_path() {
if [ "$version" = "system" ]; then
path=$(echo "$PATH" | sed -e "s|$ASDF_DIR/shims||g; s|::|:|g")
cmd=$(basename "$executable_path")
cmd_path=$(PATH=$path which "$cmd" 2>&1)
cmd_path=$(PATH=$path command -v "$cmd" 2>&1)
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
return 1

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck source=lib/utils.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/utils.sh
. "$(dirname "$BATS_TEST_DIRNAME")"/lib/utils.sh
setup_asdf_dir() {
BASE_DIR=$(mktemp -dt asdf.XXXX)

View File

@ -2,10 +2,10 @@
load test_helpers
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/update.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/uninstall.sh
. $(dirname "$BATS_TEST_DIRNAME")/lib/commands/update.sh
. $(dirname "$BATS_TEST_DIRNAME")/lib/commands/reshim.sh
. $(dirname "$BATS_TEST_DIRNAME")/lib/commands/install.sh
. $(dirname "$BATS_TEST_DIRNAME")/lib/commands/uninstall.sh
setup() {
setup_asdf_dir