Handle cmdline variable correct, so getopts style s/ms work as they should
authorJoerg Jaspert <joerg@ganneff.de>
Fri, 19 Jul 2013 11:18:57 +0000 (13:18 +0200)
committerJoerg Jaspert <joerg@ganneff.de>
Fri, 19 Jul 2013 11:18:57 +0000 (13:18 +0200)
bin/tm

diff --git a/bin/tm b/bin/tm
index ce6f95a..74430ba 100755 (executable)
--- a/bin/tm
+++ b/bin/tm
@@ -92,8 +92,8 @@ else
     DOUBLENAME=false
 fi
 
-# Store the commandline
-declare -r cmdline=${1:-""}
+# Store the first commandline parameter
+cmdline=${1:-""}
 
 # Get the tmux version and split it in major/minor
 TMUXVERS=$(tmux -V 2>/dev/null || echo "tmux 1.3")
@@ -234,6 +234,7 @@ case ${cmdline} in
         # allow us to have. And so that we can reopen an existing session, if called
         # with the same hosts again.
         SESSION=$(ssh_sessname $@)
+        declare -r cmdline
         ;;
     -*)
         while getopts "lnhs:m:c:e:" OPTION; do
@@ -244,9 +245,11 @@ case ${cmdline} in
                     ;;
                 s) # ssh
                     SESSION=$(ssh_sessname s ${OPTARG})
+                    declare -r cmdline=s
                     ;;
                 m) # ms (needs hostnames in "")
                     SESSION=$(ssh_sessname ms ${OPTARG})
+                    declare -r cmdline=ms
                     ;;
                 c) # pre-defined config
                     own_config ${OPTARG}