X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=subcommand;h=7318c9e880396e5118a117639050fac2ba063e95;hb=ab6d0fe33f57bb305b8d7e5f8bed0642d1b099d5;hp=34553b808970e92ae29f5f2dbce060c1cc2f6ae7;hpb=7118adb657e4baaa35515622057fc79a60788992;p=gsu.git diff --git a/subcommand b/subcommand index 34553b8..7318c9e 100644 --- a/subcommand +++ b/subcommand @@ -4,7 +4,7 @@ if [[ "$(type -t _gsu_setup)" != "function" ]]; then gsu_dir=${gsu_dir:-${BASH_SOURCE[0]%/*}} - . $gsu_dir/common || exit 1 + . "$gsu_dir/common" || exit 1 _gsu_setup fi @@ -46,7 +46,7 @@ _gsu_available_commands() # otherwise delete it d - ' $0 + ' "$0" } | sort | tr '\n' ' ')" } @@ -300,7 +300,7 @@ com_man() echo "${equal_signs:0:${#gsu_name} + ${#gsu_banner_txt} + 16}" echo - sed -e '1,/^#\{70,\}/d' -e '/^#\{70,\}/,$d' $0 -e 's/^# *//' + sed -e '1,/^#\{70,\}/d' -e '/^#\{70,\}/,$d' "$0" -e 's/^# *//' echo "----" echo echo "$gsu_name usage" @@ -320,7 +320,7 @@ com_man() echo "${minus_signs:0:$num}" echo "$com" echo "${minus_signs:0:$num}" - $0 help $com + "$0" help "$com" echo done } | $pager @@ -414,7 +414,7 @@ com_help() ret=$GSU_SUCCESS _gsu_get_command_regex "$1" ere="$result" - if ! grep -Eq "$ere" $0; then + if ! grep -Eq "$ere" "$0"; then _gsu_print_available_commands result="$1" ret=-$E_GSU_BAD_COMMAND @@ -437,7 +437,7 @@ com_help() :p p } - ' $0 + ' "$0" } complete_help() @@ -476,8 +476,8 @@ EOF words=("$@") cmd="${words[1]}" ret=$GSU_SUCCESS # It's not an error if no completer was defined - [[ "$(type -t complete_$cmd)" != "function" ]] && return - complete_$cmd "$cword" "${words[@]}" + [[ "$(type -t "complete_$cmd")" != "function" ]] && return + "complete_$cmd" "$cword" "${words[@]}" # ignore errors, they would only clutter the completion output ret=$GSU_SUCCESS } @@ -493,7 +493,8 @@ EOF # gsu_cword_is_option_parameter() { - local opts="$1" cword="$2" prev i n + local opts="$1" cword="$2" + local opt prev i n local -a words result= @@ -510,7 +511,7 @@ gsu_cword_is_option_parameter() opt="${opts:$i:1}" [[ "${opts:$(($i + 1)):1}" != ":" ]] && continue let i++ - [[ "$prev" != "-$opt" ]] && continue + [[ ! "$prev" =~ ^-.*$opt$ ]] && continue result="$opt" return done @@ -584,8 +585,8 @@ gsu() fi arg="$1" shift - if [[ "$(type -t com_$arg)" == 'function' ]]; then - com_$arg "$@" + if [[ "$(type -t "com_$arg")" == 'function' ]]; then + "com_$arg" "$@" if (("$ret" < 0)); then gsu_err_msg exit 1