Merge pull request #1013 from blueyed/shellcheck

Fix some issues reported by shellcheck
This commit is contained in:
Mislav Marohnić 2017-11-30 11:43:18 +01:00 committed by GitHub
commit 6aa70b6541
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 11 deletions

View file

@ -21,7 +21,8 @@ abort() {
if enable -f "${BASH_SOURCE%/*}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then if enable -f "${BASH_SOURCE%/*}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then
abs_dirname() { abs_dirname() {
local path="$(realpath "$1")" local path
path="$(realpath "$1")"
echo "${path%/*}" echo "${path%/*}"
} }
else else

View file

@ -28,15 +28,15 @@ shopt -s nullglob
for command in "${path}/rbenv-"*; do for command in "${path}/rbenv-"*; do
command="${command##*rbenv-}" command="${command##*rbenv-}"
if [ -n "$sh" ]; then if [ -n "$sh" ]; then
if [ ${command:0:3} = "sh-" ]; then if [ "${command:0:3}" = "sh-" ]; then
echo ${command##sh-} echo "${command##sh-}"
fi fi
elif [ -n "$nosh" ]; then elif [ -n "$nosh" ]; then
if [ ${command:0:3} != "sh-" ]; then if [ "${command:0:3}" != "sh-" ]; then
echo ${command##sh-} echo "${command##sh-}"
fi fi
else else
echo ${command##sh-} echo "${command##sh-}"
fi fi
done done
done done

View file

@ -42,6 +42,7 @@ extract_initial_comment_block() {
} }
collect_documentation() { collect_documentation() {
# shellcheck disable=SC2016
$(type -p gawk awk | head -1) ' $(type -p gawk awk | head -1) '
/^Summary:/ { /^Summary:/ {
summary = substr($0, 10) summary = substr($0, 10)
@ -86,7 +87,8 @@ collect_documentation() {
} }
documentation_for() { documentation_for() {
local filename="$(command_path "$1")" local filename
filename="$(command_path "$1")"
if [ -n "$filename" ]; then if [ -n "$filename" ]; then
extract_initial_comment_block < "$filename" | collect_documentation extract_initial_comment_block < "$filename" | collect_documentation
fi fi
@ -114,7 +116,7 @@ print_help() {
eval "$(documentation_for "$command")" eval "$(documentation_for "$command")"
[ -n "$help" ] || help="$summary" [ -n "$help" ] || help="$summary"
if [ -n "$usage" -o -n "$summary" ]; then if [ -n "$usage" ] || [ -n "$summary" ]; then
if [ -n "$usage" ]; then if [ -n "$usage" ]; then
echo "$usage" echo "$usage"
else else

View file

@ -83,7 +83,7 @@ remove_outdated_shims() {
list_executable_names() { list_executable_names() {
local version file local version file
rbenv-versions --bare --skip-aliases | \ rbenv-versions --bare --skip-aliases | \
while read version; do while read -r version; do
for file in "${RBENV_ROOT}/versions/${version}/bin/"*; do for file in "${RBENV_ROOT}/versions/${version}/bin/"*; do
echo "${file##*/}" echo "${file##*/}"
done done
@ -136,6 +136,7 @@ shopt -s nullglob
# executables. # executables.
create_prototype_shim create_prototype_shim
remove_outdated_shims remove_outdated_shims
# shellcheck disable=SC2046
make_shims $(list_executable_names | sort -u) make_shims $(list_executable_names | sort -u)

View file

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Summary: Display the root directory where versions and shims are kept # Summary: Display the root directory where versions and shims are kept
echo $RBENV_ROOT echo "$RBENV_ROOT"

View file

@ -20,7 +20,7 @@ fi
whence() { whence() {
local command="$1" local command="$1"
rbenv-versions --bare | while read version; do rbenv-versions --bare | while read -r version; do
path="$(rbenv-prefix "$version")/bin/${command}" path="$(rbenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version" [ "$print_paths" ] && echo "$path" || echo "$version"