X-Git-Url: http://git.tuebingen.mpg.de/?p=gsu.git;a=blobdiff_plain;f=funcs%2Fgsu;h=136eda645e86fe39ebb6d8ea863f09487ce3fb79;hp=0403039f90661a3ac36ce534c5e8befff37e5a4b;hb=e264bb74ebea7f0e9b783514f2abff6b83cc2421;hpb=fc285d975bf7d8e7a4c06c7c90eabe55d4d9d79d diff --git a/funcs/gsu b/funcs/gsu index 0403039..136eda6 100644 --- a/funcs/gsu +++ b/funcs/gsu @@ -1,4 +1,3 @@ -#!/bin/bash # gsu -- the global subcommand utility # (C) 2006-2007 Andre Noll @@ -10,8 +9,7 @@ E_GSU_BAD_COMMAND invalid command E_GSU_NOT_A_NUMBER not a number $gsu_errors " - local a b i - local i=0 + local a b i=0 while read a b; do if test -z "$a"; then continue @@ -19,7 +17,7 @@ $gsu_errors #echo "a:$a, b: $b" gsu_error_txt[i]="$b" eval $a=$i - i=$((i + 1)) + i=$(($i + 1)) done << EOF $gsu_errors EOF @@ -87,7 +85,7 @@ gsu_err_msg() else txt="${gsu_error_txt[$err]}" fi - echo "$gsu_self: $txt" 1>&2 + gsu_msg "$txt" } export -f gsu_err_msg @@ -120,14 +118,14 @@ com_help() | sed -e 's/^com_\([a-zA-Z_0-9]\+\)()#*/\1\t/' \ | sort \ | while read a b; do - echo -en "$a\t" - if test ${#a} -lt 8; then - echo -en "\t" - fi - echo "$b" + printf "$a\t" + if test ${#a} -lt 8; then + printf "\t" + fi + echo "$b" done echo - gsu_msg "Try $0 help for info on ." + gsu_msg "Try $gsu_self help for info on ." ret=$GSU_SUCCESS return fi @@ -163,8 +161,8 @@ gsu_print_available_commands() gsu_short_msg "Available commands:" for i in $gsu_cmds; do printf "$i" - count=$((count + 1)) - if test $((count % 4)) -eq 0; then + count=$(($count + 1)) + if test $(($count % 4)) -eq 0; then echo else printf "\t" @@ -180,6 +178,8 @@ export -f gsu_print_available_commands gsu() { + local i + gsu_self="$(basename $0)" gsu_init_errors gsu_available_commands @@ -193,7 +193,8 @@ gsu() shift for i in $gsu_cmds; do if test "$arg" = "$i"; then - com_$arg $* + com_$arg "$@" + ret=1 if test $ret -lt 0; then gsu_err_msg exit 1