Shell variables may be referenced by name without using the parameter
expansion syntax. In fact, this is to be preferred. Also no quotes
are neccessary.
This also fixes the hello world example.
Reported-by: Johannes Woerner <woerner@tuebingen.mpg.de>
Tested-by: Johannes Woerner <woerner@tuebingen.mpg.de>
gsu_getopts 't:v'
eval "$result"
gsu_getopts 't:v'
eval "$result"
[[ -z "$o_t" ]] && o_t='ext3' # default to ext3 if -t is not given
[[ "$o_v" == 'true' ]] && awk_field=0 # $0 is the whole line
[[ -z "$o_t" ]] && o_t='ext3' # default to ext3 if -t is not given
[[ "$o_v" == 'true' ]] && awk_field=0 # $0 is the whole line
com_world()
{
gsu_check_arg_count $# 0 0 # no arguments allowed
com_world()
{
gsu_check_arg_count $# 0 0 # no arguments allowed
local optstring='t:v'
gsu_complete_options $optstring "$@"
local optstring='t:v'
gsu_complete_options $optstring "$@"
gsu_cword_is_option_parameter $optstring "$@"
[[ "$result" == 't' ]] && awk '{print $3}' "$f"
gsu_cword_is_option_parameter $optstring "$@"
[[ "$result" == 't' ]] && awk '{print $3}' "$f"
local username
gsu_inputbox 'Enter username' "$LOGNAME"
local username
gsu_inputbox 'Enter username' "$LOGNAME"
- (($ret != 0)) && return
username="$result"
gsu_msgbox "$(pgrep -lu "$username")"
}
username="$result"
gsu_msgbox "$(pgrep -lu "$username")"
}
local username
gsu_inputbox 'Enter username' "$LOGNAME"
local username
gsu_inputbox 'Enter username' "$LOGNAME"
username="$result"
gsu_msgbox "$(pgrep -lu "$username")"
}
username="$result"
gsu_msgbox "$(pgrep -lu "$username")"
}
#echo "a:$a, b: $b"
gsu_error_txt[i]="$b"
eval $a=$i
#echo "a:$a, b: $b"
gsu_error_txt[i]="$b"
eval $a=$i
done << EOF
$gsu_errors
EOF
done << EOF
$gsu_errors
EOF
local txt="$result" err
gsu_is_a_number "$ret"
local txt="$result" err
gsu_is_a_number "$ret"
gsu_msg "unknown error ($ret:$txt)"
exit 1
fi
gsu_msg "unknown error ($ret:$txt)"
exit 1
fi
- if (($result >= 0)); then
+ if ((result >= 0)); then
gsu_msg "unknown error ($result:$txt)"
exit 1
fi
gsu_msg "unknown error ($result:$txt)"
exit 1
fi
if test -n "$txt"; then
txt="$txt: ${gsu_error_txt[$err]}"
else
if test -n "$txt"; then
txt="$txt: ${gsu_error_txt[$err]}"
else
;;
num)
gsu_is_a_number "$val"
;;
num)
gsu_is_a_number "$val"
;;
*)
ret=-$E_GSU_BAD_OPTION_TYPE
;;
*)
ret=-$E_GSU_BAD_OPTION_TYPE
gsu_check_options_or_die()
{
gsu_check_options
gsu_check_options_or_die()
{
gsu_check_options
fi
x="${result#* }"
y="${result%% *}"
fi
x="${result#* }"
y="${result%% *}"
# Some versions of dialog segfault if the text is too long. Hence we
# always use a temporary file.
gsu_make_tempfile 'gsu_msgbox.XXXXXXXXXX'
# Some versions of dialog segfault if the text is too long. Hence we
# always use a temporary file.
gsu_make_tempfile 'gsu_msgbox.XXXXXXXXXX'
tmp="$result"
trap "rm -f $tmp" EXIT
echo "$1" > "$tmp"
tmp="$result"
trap "rm -f $tmp" EXIT
echo "$1" > "$tmp"
#echo "line: $line_num, root: $root, indent level: $level"
result="$(sed -e "1,${line_num}d;" <<< "$tree" \
| sed -e "/^$TAB\{1,$level\}$_gsu_node_name_pattern/,\$d" \
#echo "line: $line_num, root: $root, indent level: $level"
result="$(sed -e "1,${line_num}d;" <<< "$tree" \
| sed -e "/^$TAB\{1,$level\}$_gsu_node_name_pattern/,\$d" \
- | sed -e "/^$TAB\{$(($level + 2))\}/d")"
+ | sed -e "/^$TAB\{$((level + 2))\}/d")"
if (($? != 0)); then
ret=-$E_GSU_MENU_TREE
result="sed command for subtree $root failed"
if (($? != 0)); then
ret=-$E_GSU_MENU_TREE
result="sed command for subtree $root failed"
while :; do
_gsu_menu "$header" "$subtree"
while :; do
_gsu_menu "$header" "$subtree"
[[ -z "$result" ]] && return # menu was cancelled
if [[ "${result%/}" != "$result" ]]; then
old_header="$header"
header="$result"
_get_subtree "$tree" "$header"
[[ -z "$result" ]] && return # menu was cancelled
if [[ "${result%/}" != "$result" ]]; then
old_header="$header"
header="$result"
_get_subtree "$tree" "$header"
_browse "$header" "$tree" "$result"
_browse "$header" "$tree" "$result"
header="$old_header"
continue
fi
header="$old_header"
continue
fi
'
gsu_check_arg_count $# 1 1
'
gsu_check_arg_count $# 1 1
result="local _gsu_getopts_opt"
for ((i=0; i < ${#1}; i++)); do
c1=${1:$i:1}
result="local _gsu_getopts_opt"
for ((i=0; i < ${#1}; i++)); do
c1=${1:$i:1}
result+=" o_$c1="
if [[ "$c2" = ":" ]]; then
let i++
result+=" o_$c1="
if [[ "$c2" = ":" ]]; then
let i++
"
for ((i=0; i < ${#1}; i++)); do
c1=${1:$i:1}
"
for ((i=0; i < ${#1}; i++)); do
c1=${1:$i:1}
result+="$tab$tab$c1) o_$c1="
if [[ "$c2" = ":" ]]; then
result+="\"\$OPTARG\""
result+="$tab$tab$c1) o_$c1="
if [[ "$c2" = ":" ]]; then
result+="\"\$OPTARG\""
for cmd in $cmds; do
printf '%s' "$cmd"
let ++count
for cmd in $cmds; do
printf '%s' "$cmd"
let ++count
- if (($count % 4)); then
printf '\t'
((${#cmd} < 8)) && printf '\t'
else
printf '\t'
((${#cmd} < 8)) && printf '\t'
else
gsu_getopts "$com_prefs_options"
eval "$result"
gsu_getopts "$com_prefs_options"
eval "$result"
gsu_check_arg_count $# 0 0
gsu_check_arg_count $# 0 0
if [[ "$o_e" == "true" ]]; then
ret=-$E_GSU_MKDIR
if [[ "$o_e" == "true" ]]; then
ret=-$E_GSU_MKDIR
_gsu_available_commands
for com in $result; do
num=${#com}
_gsu_available_commands
for com in $result; do
num=${#com}
echo "${minus_signs:0:$num}"
echo "$com"
echo "${minus_signs:0:$num}"
echo "${minus_signs:0:$num}"
echo "$com"
echo "${minus_signs:0:$num}"
cword="$1"
gsu_is_a_number "$cword"
cword="$1"
gsu_is_a_number "$cword"
- (($ret < 0)) && return
- if (($cword <= 1)); then
+ ((ret < 0)) && return
+ if ((cword <= 1)); then
_gsu_available_commands
echo "${result}"
ret=$GSU_SUCCESS
_gsu_available_commands
echo "${result}"
ret=$GSU_SUCCESS
- (($cword == 0)) && return
+ ((cword == 0)) && return
((${#opts} < 2)) && return
shift 2
words=("$@")
((${#opts} < 2)) && return
shift 2
words=("$@")
- prev="${words[$(($cword - 1))]}"
+ prev="${words[$((cword - 1))]}"
[[ ! "$prev" == -* ]] && return
n=$((${#opts} - 1))
for ((i=0; i <= $n; i++)); do
opt="${opts:$i:1}"
[[ ! "$prev" == -* ]] && return
n=$((${#opts} - 1))
for ((i=0; i <= $n; i++)); do
opt="${opts:$i:1}"
- [[ "${opts:$(($i + 1)):1}" != ":" ]] && continue
+ [[ "${opts:$((i + 1)):1}" != ":" ]] && continue
let i++
[[ ! "$prev" =~ ^-.*$opt$ ]] && continue
result="$opt"
let i++
[[ ! "$prev" =~ ^-.*$opt$ ]] && continue
result="$opt"
shift 2
words=("$@")
cur="${words[$cword]}"
shift 2
words=("$@")
cur="${words[$cword]}"
- prev="${words[$(($cword - 1))]}"
+ prev="${words[$((cword - 1))]}"
result=-1
[[ "$cur" == -* ]] && return
[[ "$prev" == -* ]] && [[ "$opts" == *${prev#-}:* ]] && return
for ((i=1; i <= $cword; i++)); do
result=-1
[[ "$cur" == -* ]] && return
[[ "$prev" == -* ]] && [[ "$opts" == *${prev#-}:* ]] && return
for ((i=1; i <= $cword; i++)); do
- prev="${words[$(($i - 1))]}"
+ prev="${words[$((i - 1))]}"
cur="${words[$i]}"
[[ "$cur" == -* ]] && continue
if [[ "$prev" == -* ]]; then
cur="${words[$i]}"
[[ "$cur" == -* ]] && continue
if [[ "$prev" == -* ]]; then
}
# Entry point for all gsu-based scripts.
}
# Entry point for all gsu-based scripts.
shift
if [[ "$(type -t "com_$arg")" == 'function' ]]; then
"com_$arg" "$@"
shift
if [[ "$(type -t "com_$arg")" == 'function' ]]; then
"com_$arg" "$@"
- if (("$ret" < 0)); then