summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-10-21 23:10:47 +0200
committerJonas Smedegaard <dr@jones.dk>2016-10-22 02:03:15 +0200
commitca0ccc561347202d69ef1161930811a54ef48322 (patch)
tree45f4190f9bca403e93f510419a016a4ec6b0cc2f
parent66bfa9d1afe3381e8e09ed9470328841d0c38714 (diff)
Change host handling: Explicit localhost means force use ssh; no host implies non-ssh (and requires -- before command).
-rwxr-xr-xxmc11
-rwxr-xr-xxsh22
2 files changed, 5 insertions, 28 deletions
diff --git a/xmc b/xmc
index 735ef64..40c20fe 100755
--- a/xmc
+++ b/xmc
@@ -1,12 +1,3 @@
#!/bin/bash
-# danish locale is broken - see http://bugs.debian.org/181027
-#export LC_ALL=C
-
-if [ $# -eq 0 ]; then
- xsh localhost mc
-elif [ $# -eq 1 -a "$1" = "su" ]; then
- xsh localhost mc su
-else
- xsh $@ mc
-fi
+exec xsh $@ -- mc
diff --git a/xsh b/xsh
index 9830df1..c7a8364 100755
--- a/xsh
+++ b/xsh
@@ -3,7 +3,7 @@
SCRIPT=$(basename $0)
usage() {
- echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [--] [remote command...]"
+ echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [-- command...]"
}
termwrapper() {
@@ -31,7 +31,6 @@ V=''
HOST=''
ssh_opts="-t"
-args=''
while [ $# -gt 0 ]; do
case $1 in
su) SU=1;;
@@ -39,25 +38,12 @@ while [ $# -gt 0 ]; do
--ssh2|-2) ssh_opts="$ssh_opts -2";;
--verbose|-v) V=1; ssh_opts="$ssh_opts -v";;
--port|-p) ssh_opts="$ssh_opts -p $2"; shift;;
- --host|-h) HOST=$1;;
- -) HOST="localhost";;
- --) shift; args="$args$@ "; break;;
+ --) shift; break;;
-*) usage; exit 1;;
- *) args="$args$1 ";;
+ *) [ -z "$HOST" ] && HOST=$1 || break;;
esac
shift
done
-set -- $args
-
-# Make sure we have a hostname
-if [ -z "$HOST" ]; then
- if [ $# -gt 0 ]; then
- HOST=$1
- shift
- else
- HOST="localhost"
- fi
-fi
# Split program name from its options
if [ $# -gt 0 ]; then
@@ -90,7 +76,7 @@ prg="$prg_base $prg_opts"
prg_su="echo -n 'Changing to root...: '; su -c \"cd; $prg\""
case "$HOST" in
- *@localhost|localhost)
+ '')
if [ -n "$SU" ]; then
termwrapper $prg_su
else