Skip to content

Commit 459fb3c

Browse files
Correctly escape newlines in tr invocations (#48)
The replacement of newlines with colons doesn't work as expected - it replaces literal `n` characters, not newlines: ``` $ echo -e "one\ntwo\nthree" | tr \\\\n : o:e two three ``` Simplify the `tr` invocation and ensure it actually replaces newlines.
1 parent fb02a70 commit 459fb3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: build_defs/java.build_defs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def java_library(name:str, srcs:list=None, src_dir:str=None, resources:list=[],
6969

7070
srcflag = '`find $SRCS_JAVAC -name "*.java"`' if src_dir else '$SRCS_JAVAC'
7171
javac_flags = " ".join(javac_flags)
72-
javac_cmd = f'mkdir -p _tmp/META-INF && "$TOOLS_JAVAC" {javac_flags} -classpath .:`{find} | tr \\\\\\\\n :` -d _tmp {srcflag}'
72+
javac_cmd = f'''mkdir -p _tmp/META-INF && "$TOOLS_JAVAC" {javac_flags} -classpath .:`{find} | tr '\\n' :` -d _tmp {srcflag}'''
7373

7474

7575
cmd = ' && '.join([
@@ -224,7 +224,7 @@ def java_runtime_image(name:str, out:str=None, modules:list, launcher_module:str
224224
if (launcher_module and not launcher_class) or (launcher_class and not launcher_module):
225225
fail("launcher_module and launcher_class must be defined together - they cannot be defined individually.")
226226
out = out or name
227-
depflags = r'`find "$TMP_DIR" -name "*.jar" | tr \\\\n :`'
227+
depflags = r'''`find "$TMP_DIR" -name "*.jar" | tr '\n' :`'''
228228
modules = ','.join(modules)
229229
default_jlink_args = [
230230
f"--module-path {depflags}:{home}/jmods",

0 commit comments

Comments
 (0)