summaryrefslogtreecommitdiff
path: root/xsh
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2002-03-10 02:31:16 +0000
committerJonas Smedegaard <dr@jones.dk>2002-03-10 02:31:16 +0000
commit89e375c6206c0236cfee646fa54aacd6a5fbadca (patch)
tree2d2a0aeb3fda0603db6b7c29249fd1f8c7204f0e /xsh
parentf0ced9e4c8ba13f7d499695d57680fc191a94b1c (diff)
xsh: Improve test syntax throughout the script.
Diffstat (limited to 'xsh')
-rwxr-xr-xxsh29
1 files changed, 16 insertions, 13 deletions
diff --git a/xsh b/xsh
index 9c7d701..9c31b06 100755
--- a/xsh
+++ b/xsh
@@ -9,8 +9,8 @@ function usage () {
function termwrapper () {
PRG=$@
title="$title $titleopt"
- [ $V ] && echo $PRG
-
+ [ "$V" = 1 ] && echo $PRG
+
# mc seem to have a bug separating upper- and lowercase with danish locale
# case $LANG in
# da_*) LANG=da;;
@@ -64,11 +64,11 @@ while [ $# -gt 0 ]; do
done
set -- $args
-if [ -z $HOST ]; then
+if [ -z "$HOST" ]; then
HOST=$1
shift
fi
-if [ -z $HOST ]; then
+if [ -z "$HOST" ]; then
usage
exit 1
fi
@@ -77,7 +77,7 @@ prg_base=$1
shift
prg_opts=$@
-if [ "$X" -a "$SU" -a ! "$SUHACK" ]; then
+if [ "$X" = 1 -a "$SU" = 1 -a "$SUHACK" != 1 ]; then
args="root@$args"
SUHACK=1
fi
@@ -87,15 +87,18 @@ if [ $HOST != "localhost" ]; then
ssh_opts="-C $ssh_opts"
fi
-[ $V ] && prg_opts="$prg_opts; sleep 4"
+# Pause for a moment if verbose
+if [ "$V" = 1 ]; then
+ prg_opts="$prg_opts; sleep 4"
+fi
## Don't open 2 shells if no program is run - Disabled for now (something wrong with the test...)
-#if [ -z $prg_base -a -z $prg_opts -a -z $SUU ]; then
+#if [ -z "$prg_base" -a -z "$prg_opts" -a $SUU != 1 ]; then
# title="$SCRIPT"
# prg_local=''
# prg_remote=''
#else
- if [ -z $prg_base ]; then
+ if [ -z "$prg_base" ]; then
title="$SCRIPT"
prg_base='/bin/bash'
else
@@ -111,7 +114,7 @@ fi
esac
prg_local="$prg_base $prg_opts_local"
- if [ $SUU ]; then
+ if [ "$SUU" = 1 ]; then
prg_remote="echo -n 'Changing to root...: '; su $su_opts -c \"cd; $prg_base $prg_opts_remote\""
else
# prg_remote="bash -i -c \"$prg_base $prg_opts_remote\""
@@ -121,20 +124,20 @@ fi
fi
#fi
-if [ ! $SU ]; then
+if [ "$SU" != 1 ]; then
if [ $HOST = "localhost" ]; then
termwrapper $prg_local
else
termwrapper ssh $ssh_opts $HOST $prg_remote
fi
else
- if [ "$SUHACK" ]; then
+ if [ "$SUHACK" = 1 ]; then
# termwrapper ssh $ssh_opts $HOST su $su_opts -c \"$prg_remote\"
termwrapper ssh $ssh_opts $HOST $prg_remote
else
titleopt="[$HOST root]"
- if [ $SUU ]; then
- if [ "x$USER" = "x" ]; then
+ if [ "$SUU" = 1 ]; then
+ if [ -z "$USER" ]; then
termwrapper ssh $ssh_opts $HOST $prg_remote
else
termwrapper ssh $ssh_opts $USER@$HOST $prg_remote