diff options
| author | 2025-09-16 08:56:16 +0200 | |
|---|---|---|
| committer | 2026-02-04 15:33:41 -0600 | |
| commit | 6aeee8738b8a34a8d0282688925a56091c865d43 (patch) | |
| tree | 795fe07bb99a076e9b53e19417b31fc29790ab32 | |
| parent | getline: Support prefill line buffer (diff) | |
Fix xcopy invocation in sh/copy
Separated parts with a space and added /-i switch, which disables prompt
by the xcopy command. I found this bug, when I was trying to create the
quickbin with `spork/declare-cc`.
| -rw-r--r-- | spork/sh.janet | 10 | ||||
| -rw-r--r-- | test/suite-sh.janet | 11 |
2 files changed, 14 insertions, 7 deletions
diff --git a/spork/sh.janet b/spork/sh.janet index 55fa741..0bfeed0 100644 --- a/spork/sh.janet +++ b/spork/sh.janet @@ -159,11 +159,11 @@ (if (= :windows (os/which)) (let [end (last (path/posix/parts src)) isdir (= (os/stat src :mode) :directory)] - (os/shell (string "C:\\Windows\\System32\\xcopy.exe" - " " - (path/win32/join ;(path/posix/parts src)) - (path/win32/join ;(if isdir [;(path/posix/parts dest) end] (path/posix/parts dest))) - "/y /s /e /i > nul"))) + (os/shell (string/join + ["C:\\Windows\\System32\\xcopy.exe" + (path/win32/join ;(path/posix/parts src)) + (path/win32/join ;(if isdir [;(path/posix/parts dest) end] (path/posix/parts dest))) + "/y /s /e /i /-i > nul"] " "))) (os/execute ["cp" "-rf" src dest] :px))) (def- shlex-grammar (peg/compile ~{:ws (set " \t\r\n") diff --git a/test/suite-sh.janet b/test/suite-sh.janet index f901539..1a5beaa 100644 --- a/test/suite-sh.janet +++ b/test/suite-sh.janet @@ -5,9 +5,10 @@ (start-suite) (def base-path "test") +(def assets-dir ["assets" "17"]) (do - (assert (deep= (os/dir (path/join base-path "assets/17")) + (assert (deep= (os/dir (path/join base-path ;assets-dir)) @["test.file"]) "test files are wrong, assets/17 should only contain test.file") (sh/copy-file (path/join base-path "assets/17/test.file") @@ -35,8 +36,14 @@ nil) "sh/rm didn't work correctly")) -(assert (deep= +(assert (deep= (sh/split ` "c d \" f" ' y z' a b a\ b --cflags `) @["c d \" f" " y z" "a" "b" "a b" "--cflags"])) +(def new-dir ["assets" "18"]) +(defer (do (os/rm (path/join base-path ;new-dir "test.file")) + (os/rmdir (path/join base-path ;new-dir))) + (sh/copy (path/join base-path ;assets-dir "test.file") + (path/join base-path ;new-dir "test.file")) + (assert (= :file (os/stat (path/join base-path ;new-dir "test.file") :mode)))) (end-suite) |
