@@ -13,13 +13,12 @@ main() {
13
13
exit 1
14
14
fi
15
15
16
- local resource=" $1 "
17
- local command=" $2 "
18
- local args=(" ${@: 3} " )
16
+ local resource=" $1 " ; shift
17
+ local command=" $1 " ; shift
19
18
20
19
case " $resource " in
21
20
" sandbox" )
22
- do_sandbox " $command " ${args[@]+ " ${args[@]} " }
21
+ do_sandbox " $command " " $@ "
23
22
;;
24
23
* )
25
24
echo " Unknown resource: $resource "
@@ -29,18 +28,17 @@ main() {
29
28
}
30
29
31
30
do_sandbox () {
32
- local command=" $1 "
33
- local args=(" ${@: 2} " )
31
+ local command=" $1 " ; shift
34
32
mkdir -p " $sandboxes_dir "
35
33
case " $command " in
36
34
" add" )
37
- do_sandbox_add ${args[@]+ " ${args[@]} " }
35
+ do_sandbox_add " $@ "
38
36
;;
39
37
" rm" )
40
- do_sandbox_rm ${args[@]+ " ${args[@]} " }
38
+ do_sandbox_rm " $@ "
41
39
;;
42
40
" ls" )
43
- do_sandbox_ls ${args[@]+ " ${args[@]} " }
41
+ do_sandbox_ls " $@ "
44
42
;;
45
43
* )
46
44
echo " Unknown command: $command "
@@ -52,11 +50,11 @@ do_sandbox() {
52
50
do_sandbox_add () {
53
51
# Command: codapi-cli sandbox add <path>
54
52
55
- if [[ " $# " -ne 1 ]]; then
53
+ local path=" ${1:- } "
54
+ if [[ -z " $path " ]]; then
56
55
echo " Usage: $0 sandbox add <path>"
57
56
exit 1
58
57
fi
59
- local path=" $1 "
60
58
61
59
# 1. Set the name of the sandbox.
62
60
local filename
@@ -149,11 +147,11 @@ do_sandbox_add() {
149
147
do_sandbox_rm () {
150
148
# Command: codapi-cli sandbox rm <name>
151
149
152
- if [[ " $# " -ne 1 ]]; then
150
+ local name=" ${1:- } "
151
+ if [[ -z " $name " ]]; then
153
152
echo " Usage: $0 sandbox rm <name>"
154
153
exit 1
155
154
fi
156
- local name=" $1 "
157
155
158
156
local target_dir=" $sandboxes_dir /$name "
159
157
if [[ ! -d " $target_dir " ]]; then
0 commit comments