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
abs_dirname() {
local path="$(realpath "$1")"
local path
path="$(realpath "$1")"
echo "${path%/*}"
}
else

View file

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

View file

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

View file

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

View file

@ -1,3 +1,3 @@
#!/usr/bin/env bash
# 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() {
local command="$1"
rbenv-versions --bare | while read version; do
rbenv-versions --bare | while read -r version; do
path="$(rbenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version"