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_INVAL invalid argument
18 E_GSU_MKDIR failed to create directory
19 E_GSU_GETOPTS getopts error
20 E_GSU_DIALOG dialog error
21 E_GSU_MKTEMP mktemp error
22 E_GSU_MENU_TREE invalid menu tree
23 E_GSU_XCMD external command failed
40 # check if $1 is a number
44 if [ "$1" -eq "$1" ] &> /dev/null; then
47 ret=-$E_GSU_NOT_A_NUMBER
58 gsu_short_msg "$gsu_name: $1"
63 gsu_short_msg "$gsu_name $(date): $1"
68 local txt="$result" err
70 gsu_is_a_number "$ret"
72 gsu_msg "unknown error ($ret:$txt)"
75 if ((result >= 0)); then
76 gsu_msg "unknown error ($result:$txt)"
80 if test -n "$txt"; then
81 txt="$txt: ${gsu_error_txt[$err]}"
83 txt="${gsu_error_txt[$err]}"
90 gsu_name="${gsu_name:-${0##*/}}"
91 gsu_config_var_prefix="${gsu_config_var_prefix:=$gsu_name}"
92 gsu_banner_txt="${gsu_banner_txt:-set \$gsu_banner_txt to customize this message}"
96 # We'd love to use mktemp -t here, but on Linux -t is deprecated in favor of
97 # --tempdir, which is not supported on *BSD. Hence we have to implement our own
100 # The second parameter to this function is optional. It is ignored if the
101 # template ($1) is an absolute path. Conversely, if the template is a relative
102 # path and a second parameter is given, $2 is assumed to be the directory in
103 # which the temporary file should be created.
109 if [[ "${template:0:1}" != '/' ]]; then # relative path
112 elif [[ -n "${TMPDIR:-}" ]]; then
117 template="$dir/$template"
119 result="$(mktemp "$template")"
122 result="template: $template"