Skip to content

Commit e83bf25

Browse files
committed
Disable echoing CMD code in copy_directory and copy_file rules on Windows
1 parent 31ab4c8 commit e83bf25

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

rules/private/copy_directory_private.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ def _copy_cmd(ctx, src, dst):
3434
# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
3535
# NB: robocopy return non-zero exit codes on success so we must exit 0 after calling it
3636
cmd_tmpl = """\
37-
if not exist \"{src}\\\" (
38-
echo Error: \"{src}\" is not a directory
39-
@exit 1
40-
)
41-
@robocopy \"{src}\" \"{dst}\" /E /MIR >NUL & @exit 0
42-
"""
37+
@ECHO OFF
38+
if not exist \"{src}\\\" (
39+
echo Error: \"{src}\" is not a directory
40+
@exit 1
41+
)
42+
@robocopy \"{src}\" \"{dst}\" /E /MIR >NUL & @exit 0
43+
"""
4344
mnemonic = "CopyDirectory"
4445
progress_message = "Copying directory %{input}"
4546

rules/private/copy_file_private.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ def copy_cmd(ctx, src, dst):
3232
output = bat,
3333
# Do not use lib/shell.bzl's shell.quote() method, because that uses
3434
# Bash quoting syntax, which is different from cmd.exe's syntax.
35-
content = "@copy /Y \"%s\" \"%s\" >NUL" % (
35+
content = """\
36+
@ECHO OFF
37+
@copy /Y \"%s\" \"%s\" >NUL
38+
""" % (
3639
src.path.replace("/", "\\"),
3740
dst.path.replace("/", "\\"),
3841
),

0 commit comments

Comments
 (0)