]> Sergey Matveev's repositories - mmc.git/commitdiff
Ability to invoke cmd/download outside state directory
authorSergey Matveev <stargrave@stargrave.org>
Sat, 11 Mar 2023 18:14:26 +0000 (21:14 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 11 Mar 2023 18:14:26 +0000 (21:14 +0300)
cmd/download

index 8a72550fb8fba926c93b7277b6aa37ad98be2198..d338ec99055ce234e403f9c73e2fce757b8ce649 100755 (executable)
@@ -1,9 +1,13 @@
 #!/bin/sh -e
 
+[ $# -eq 2 ] || {
+    echo "Usage: $0 path/to/state fileId" >&2
+    exit 1
+}
 tmp=`mktemp`
 trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
-echo $1 > file/get &
-cat file/out > $tmp
-mv $tmp $1.tar
-echo $1.tar
-tar tvf $1.tar
+echo $2 > "$1"/file/get &
+cat "$1"/file/out > $tmp
+mv $tmp $2.tar
+echo $2.tar
+tar tvf $2.tar