From: Andre Noll Date: Sun, 31 Aug 2014 19:01:02 +0000 (+0200) Subject: Unify gsu_dir handling. X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=8d89aa241a5199b0a25edcf0e56da08c64aa4014;p=gsu.git Unify gsu_dir handling. The three locations which include the common part of gsu need to know the gsu installation directory. Currently we rely on the application to set $gsu_dir. This is unnecessary since gsu can tell where it is installed by examining ${BASH_SOURCE[0]}. Also the fallback to $HOME/.gsu is not required. This commit unifies all three locations and also calls _gsu_setup as early as possible: when the gsu module is sourced. --- diff --git a/config b/config index 09330f3..7667cf5 100644 --- a/config +++ b/config @@ -79,7 +79,7 @@ gsu_check_options_or_die() } if [[ "$(type -t _gsu_setup)" != "function" ]]; then - gsu_dir=${gsu_dir:=${HOME:-}/.gsu} + gsu_dir=${gsu_dir:-${BASH_SOURCE[0]%/*}} . $gsu_dir/common || exit 1 _gsu_setup fi diff --git a/gui b/gui index eb9f29f..72717a1 100644 --- a/gui +++ b/gui @@ -1,8 +1,9 @@ #!/bin/bash -if [[ $(type -t gsu_is_a_number) != "function" ]]; then - GSU_DIR=${GSU_DIR:=${HOME:-}/.gsu} - . $GSU_DIR/common || exit 1 +if [[ "$(type -t _gsu_setup)" != "function" ]]; then + gsu_dir=${gsu_dir:-${BASH_SOURCE[0]%/*}} + . $gsu_dir/common || exit 1 + _gsu_setup fi export GSU_NODE_NAME_PATTERN='[a-zA-Z_]' @@ -200,7 +201,6 @@ gsu_gui() { local tree="$1" subtree - _gsu_setup type -t dialog &> /dev/null if (($? != 0)); then gsu_msg "dialog executable not found" diff --git a/subcommand b/subcommand index 6b5df0a..bab8ded 100644 --- a/subcommand +++ b/subcommand @@ -1,9 +1,10 @@ #!/bin/bash # (C) 2006-2011 Andre Noll -if [[ $(type -t gsu_is_a_number) != "function" ]]; then - GSU_DIR=${GSU_DIR:=${HOME-}/.gsu} - . $GSU_DIR/common || exit 1 +if [[ "$(type -t _gsu_setup)" != "function" ]]; then + gsu_dir=${gsu_dir:-${BASH_SOURCE[0]%/*}} + . $gsu_dir/common || exit 1 + _gsu_setup fi _gsu_usage() @@ -531,7 +532,6 @@ gsu_get_unnamed_arg_num() gsu() { local i - _gsu_setup _gsu_available_commands gsu_cmds="$result" if test $# -eq 0; then