2 # Copyright (C) 2006 Andre Noll
3 # Licensed under the LGPL, version 3. See COPYING and COPYING.LESSER.
9 E_GSU_BAD_COMMAND invalid command
10 E_GSU_NOT_A_NUMBER not a number
11 E_GSU_BAD_CONFIG_VAR invalid config variable
12 E_GSU_NEED_VALUE value required but not given
13 E_GSU_BAD_BOOL bad value for boolian option
14 E_GSU_BAD_OPTION_TYPE invalid option type
15 E_GSU_BAD_ARG_COUNT invalid number of arguments
16 E_GSU_EDITOR failed to execute editor
17 E_GSU_MKDIR failed to create directory
18 E_GSU_GETOPTS getopts error
19 E_GSU_DIALOG dialog error
20 E_GSU_MKTEMP mktemp error
21 E_GSU_MENU_TREE invalid menu tree
38 # check if $1 is a number
42 if [ "$1" -eq "$1" ] &> /dev/null; then
45 ret=-$E_GSU_NOT_A_NUMBER
56 gsu_short_msg "$gsu_name: $1"
61 gsu_short_msg "$gsu_name $(date): $1"
66 local txt="$result" err
68 gsu_is_a_number "$ret"
70 gsu_msg "unknown error ($ret:$txt)"
73 if (($result >= 0)); then
74 gsu_msg "unknown error ($result:$txt)"
78 if test -n "$txt"; then
79 txt="$txt: ${gsu_error_txt[$err]}"
81 txt="${gsu_error_txt[$err]}"
88 gsu_name="${gsu_name:-${0##*/}}"
89 gsu_config_var_prefix="${gsu_config_var_prefix:=$gsu_name}"
90 gsu_banner_txt="${gsu_banner_txt:-set \$gsu_banner_txt to customize this message}"
94 # We'd love to use mktemp -t here, but on Linux -t is deprecated in favor of
95 # --tempdir, which is not supported on *BSD. Hence we have to implement our own
98 # The second parameter to this function is optional. It is ignored if the
99 # template ($1) is an absolute path. Conversely, if the template is a relative
100 # path and a second parameter is given, $2 is assumed to be the directory in
101 # which the temporary file should be created.
107 if [[ "${template:0:1}" != '/' ]]; then # relative path
110 elif [[ -n "$TMPDIR" ]]; then
115 template="$dir/$template"
117 result="$(mktemp "$template")"
120 result="template: $template"