]> hydra-www.ietfng.org Git - csdb/commitdiff
Use -- in generated shell commands
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 19 Feb 2022 10:14:49 +0000 (10:14 +0000)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 19 Feb 2022 10:14:49 +0000 (10:14 +0000)
Deal with paths beginning with '-'

cdb
test.sh

diff --git a/cdb b/cdb
index df50eaf093ed2dc5f163cb49db110dab584709f1..6474daa975e300ebcac441b4cc48d807ad75e278 100755 (executable)
--- a/cdb
+++ b/cdb
@@ -315,7 +315,7 @@ mksubcmd(function(c)
                         " to ", human_escape(q), "\n")
       end
       io.write(args.move and "mv" or "cp",
-        " ", shell_escape(p), " ", shell_escape(q), eol)
+        " -- ", shell_escape(p), " ", shell_escape(q), eol)
       log_new_hash(h, q)
     elseif args.inplace then
       io.stderr:write("Adding in place ", human_escape(p), "\n")
diff --git a/test.sh b/test.sh
index 07e3edd85f16bd59ed3726fb2ab84abc03cc77a5..16f5758b6e01d3adbf76df7b05629ffb5f819ac7 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -158,8 +158,8 @@ ti'cky copy with \$extra
 HERE
 
 diff -u - <(${LUA} ./cdb --db ${DB1} ingest --move --target x --digest-log ${LOG2} <${LOG1}) <<HERE
-mv 'new' 'x/new'
-mv 'new\\esc' 'x/new\\esc'
+mv -- 'new' 'x/new'
+mv -- 'new\\esc' 'x/new\\esc'
 HERE
 diff -u - ${LOG2} <<HERE
 5  x/new
@@ -183,9 +183,9 @@ HERE
 
 # And with some rude characters in the path name
 diff -u - <(${LUA} ./cdb --db ${DB1} ingest --target x <<<'5  rude'$'\r''new') \
-          <<<"cp 'rude"$'\r'"new' 'x/rude"$'\r'"new'"
+          <<<"cp -- 'rude"$'\r'"new' 'x/rude"$'\r'"new'"
 diff -u - <(${LUA} ./cdb --db ${DB1} ingest --target x --extended-escapes <<<'5  rude'$'\t''new') \
-          <<<"cp 'rude'\$'\\x09''new' 'x/rude'\$'\\x09''new'"
+          <<<"cp -- 'rude'\$'\\x09''new' 'x/rude'\$'\\x09''new'"
 diff -u - <(${LUA} ./cdb --db ${DB1} ingest --target x --verbose 2>&1 <<<'9  rude'$'\r''copy') \
           <<<"Import hash 9 from path 'rude'$'\\x0d''copy' already in database at 'twinned'"