Skip to content

Commit a5b2a39

Browse files
committed
fix for #73 - allow to mix order of files and arguments
1 parent 177b5ad commit a5b2a39

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

rmate

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function canonicalize {
136136
fi
137137

138138
local dir=$(dirpath "$filepath")
139-
139+
140140
if [ -L "$filepath" ]; then
141141
relativepath=$(cd "$dir" || { echo "unable to cd to $dir" 1>&2; exit; } ; readlink "$(basename "$filepath")")
142142
result=$(dirpath "$relativepath")/$(basename "$relativepath")
@@ -148,14 +148,14 @@ function canonicalize {
148148
result="$dir/$result"
149149
fi
150150
fi
151-
151+
152152
echo "$result"
153153
}
154154

155-
while [[ "${1:0:1}" = "-" || "$1" =~ ^\+([0-9]+)$ ]]; do
155+
while [[ "$1" != "" ]]; do
156156
case $1 in
157157
-)
158-
break
158+
filepaths+=("-")
159159
;;
160160
--)
161161
shift
@@ -204,12 +204,16 @@ while [[ "${1:0:1}" = "-" || "$1" =~ ^\+([0-9]+)$ ]]; do
204204
showusage
205205
exit 1
206206
;;
207-
+[0-9]*)
207+
+[0-9][0-9]*)
208208
selections+=(${1:1})
209209
;;
210210
*)
211-
showusage
212-
exit 1
211+
if [[ "${1:0:1}" = "-" ]]; then
212+
showusage
213+
exit 1
214+
else
215+
filepaths+=("$1")
216+
fi
213217
;;
214218
esac
215219

@@ -220,7 +224,7 @@ if [[ "$host" = "auto" && "$SSH_CONNECTION" != "" ]]; then
220224
host=${SSH_CONNECTION%% *}
221225
fi
222226

223-
filepaths=("$@")
227+
filepaths=("${filepaths[@]}" "$@")
224228

225229
if [ "${filepaths[*]}" = "" ]; then
226230
if [[ $nowait = false ]]; then

0 commit comments

Comments
 (0)