summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-06-12 22:35:39 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-06-12 22:35:39 +0200
commiteeb82be0eb59a680309858fe9a42261451bc2897 (patch)
tree0c3135d3bc4e2942e71bbf8c7bb538562f002649 /scripts
parent964f899f665a14455b527890f445f6cb2f1d4576 (diff)
downloadnetctl-eeb82be0eb59a680309858fe9a42261451bc2897.tar.gz
netctl-eeb82be0eb59a680309858fe9a42261451bc2897.tar.xz
New style to check command availability
When we don't really care which file implements the needed command (i.e. we don't call it by its full path), we use type to establish availability of the command. In wifi-menu we add a check for the dialog command and remove potential clearing of relevant error messages.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/netcfg-menu2
-rwxr-xr-xscripts/pm-utils2
-rwxr-xr-xscripts/wifi-menu5
3 files changed, 5 insertions, 4 deletions
diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu
index b6aa402..d0db762 100755
--- a/scripts/netcfg-menu
+++ b/scripts/netcfg-menu
@@ -2,7 +2,7 @@
. /usr/lib/network/network
-if [[ ! -x /usr/bin/dialog ]]; then
+if ! type dialog &> /dev/null; then
echo "Please install 'dialog' to use netcfg-menu"
exit 1
fi
diff --git a/scripts/pm-utils b/scripts/pm-utils
index 311851f..93ee763 100755
--- a/scripts/pm-utils
+++ b/scripts/pm-utils
@@ -10,7 +10,7 @@ resume_netcfg() {
netcfg all-resume
}
-if [ -x /usr/bin/netcfg ]; then
+if type netcfg > /dev/null; then
case "$1" in
hibernate|suspend)
suspend_netcfg
diff --git a/scripts/wifi-menu b/scripts/wifi-menu
index 96f6de1..1140b85 100755
--- a/scripts/wifi-menu
+++ b/scripts/wifi-menu
@@ -193,6 +193,9 @@ fi
if [[ $(id -u) -ne 0 ]]; then
exit_stderr "This script needs to be run with root privileges"
fi
+if ! type dialog &> /dev/null; then
+ exit_stderr "Please install 'dialog' to use wifi-menu"
+fi
INTERFACE=${1-$WIRELESS_INTERFACE}
if [[ -z "$INTERFACE" ]]; then
@@ -245,7 +248,6 @@ case $RETURN in
report_err "No networks found"
;;
4) # Unable to create profile
- clear
report_err "Could not create a profile for '$CHOICE'"
;;
255) # ESC or error
@@ -253,7 +255,6 @@ case $RETURN in
report_err "Aborted"
;;
*) # Should not happen
- clear
report_err "Unexpected return code from dialog: $RETURN"
RETURN=7
;;