summaryrefslogtreecommitdiff
path: root/scripts/xdg-su
diff options
context:
space:
mode:
authorWaldo Bastian <waldo.bastian@intel.com>2006-06-10 00:42:03 +0000
committerWaldo Bastian <waldo.bastian@intel.com>2006-06-10 00:42:03 +0000
commitc19c8abaf1519608a052c10dd7547f18d50d66ce (patch)
tree5e3e201b08e6542f718c67da429a18d0ddacb678 /scripts/xdg-su
parentc460cf3430df6aabcc3f3680adcc1c3568286969 (diff)
* Merged exit_failure_arg_malformed and exit_failure_arg_count into a single
exit_failure_syntax * Added exit_failure_file_missing * Added exit codes to documentation * Fixed BR715: - Don't access X server when not needed - document commands that require desktop session * Added "make man" target to update man pages
Diffstat (limited to 'scripts/xdg-su')
-rwxr-xr-xscripts/xdg-su38
1 files changed, 18 insertions, 20 deletions
diff --git a/scripts/xdg-su b/scripts/xdg-su
index afb1ca8..0e694c1 100755
--- a/scripts/xdg-su
+++ b/scripts/xdg-su
@@ -79,14 +79,15 @@ exit_success()
#-----------------------------------------
-# Exit script on wrong number of arguments
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
# prints usage information
-exit_failure_arg_count()
+exit_failure_syntax()
{
if [ $# -gt 0 ]; then
- echo "$@"
- echo
+ echo "$@" >&2
+ echo >&2
fi
usage
@@ -94,20 +95,16 @@ exit_failure_arg_count()
exit 1
}
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
-#-----------------------------------
-# Exit script on malformed arguments
-# prints usage information
-
-exit_failure_arg_malformed()
+exit_failure_file_missing()
{
if [ $# -gt 0 ]; then
- echo "$@"
- echo
+ echo "$@" >&2
+ echo >&2
fi
- usage
-
exit 2
}
@@ -117,8 +114,8 @@ exit_failure_arg_malformed()
exit_failure_operation_impossible()
{
if [ $# -gt 0 ]; then
- echo "$@"
- echo
+ echo "$@" >&2
+ echo >&2
fi
exit 3
@@ -130,13 +127,14 @@ exit_failure_operation_impossible()
exit_failure_operation_failed()
{
if [ $# -gt 0 ]; then
- echo "$@"
- echo
+ echo "$@" >&2
+ echo >&2
fi
exit 4
}
+
#----------------------------------------
# Checks for shared commands, e.g. --help
@@ -175,8 +173,6 @@ detectDE()
fi
}
-detectDE
-
#----------------------------------------------------------------------------
@@ -224,7 +220,9 @@ su_generic()
fi
}
-[ x"$1" != x"" ] || exit_failure_arg_count
+[ x"$1" != x"" ] || exit_failure_syntax
+
+detectDE
if [ x"$DE" = x"" ]; then
XSU=`which xsu 2>/dev/null`