Skip to content

Commit 252e683

Browse files
authored
Merge pull request #84 from groner/desk-run-argv
Make desk run work with an argument vector.
2 parents 775cc4a + 950adb0 commit 252e683

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

desk

+10-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ Usage:
3030
Activate a desk. Extra arguments are passed onto shell. If called with
3131
no arguments, look for a Deskfile in the current directory. If not a
3232
recognized desk, try as a path to directory containing a Deskfile.
33-
$PROGRAM run <desk-name> <cmd>
34-
Run a command within a desk's environment then exit. Think '\$SHELL -c'.
33+
$PROGRAM run <desk-name> '<cmd>'
34+
$PROGRAM run <desk-name> <cmd> <arg>...
35+
Run a command within a desk's environment then exit. In the first form
36+
shell expansion is performed. In the second form, the argument vector
37+
is executed as is.
3538
$PROGRAM edit [desk-name]
3639
Edit (or create) a deskfile with the name specified, otherwise
3740
edit the active deskfile.
@@ -138,7 +141,11 @@ cmd_go() {
138141
cmd_run() {
139142
local TODESK="$1"
140143
shift;
141-
cmd_go "$TODESK" -ic "$@"
144+
if [ $# -eq 1 ]; then
145+
cmd_go "$TODESK" -ic "$1"
146+
else
147+
cmd_go "$TODESK" -ic '"$@"' -- "$@"
148+
fi
142149
}
143150

144151

test/run_tests.sh

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ RAN=$(desk run hello 'echo $MyName')
139139
echo "$RAN" | grep 'James' >/dev/null
140140
ensure $? "Run in desk 'hello' didn't work with MyName exported variable"
141141

142+
RAN=$(desk run hello echo ahoy matey)
143+
echo "$RAN" | grep 'ahoy matey' >/dev/null
144+
ensure $? "Run in desk 'hello' didn't work with argument vector"
145+
142146
## `desk go`
143147

144148
RAN=$(desk go example-project/Deskfile -c 'desk ; exit')

0 commit comments

Comments
 (0)