Skip to content

Commit 25685fc

Browse files
committed
meson: use better shellscript argument passing
Cherry-pick systemd commit ac3eda34[1] ("meson: use better shellscript argument passing"): Passing potentially arbitrary data into a shellscript is potentially very broken if you do not correctly quote it for use. This quoting must be done as part of the interpretation of the data itself, e.g. python's shlex.quote; simply formatting it into a string with double quotes is NOT sufficient. An alternative is to communicate the data reliably via argv to the shell process, and allow the shell to internally handle it via `"$1"`, which is quote-safe and will expand the data from argv as a single tokenized word. Also silences the following meson deprecation notice: NOTICE: Future-deprecated features used: * 0.55.0: {'ExternalProgram.path'} [1]: systemd/systemd@ac3eda3
1 parent b733edf commit 25685fc

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ gperf_test_format = '''
109109
const char * in_word_set(const char *, @0@);
110110
@1@
111111
'''
112-
gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
113-
gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()), check: true)
112+
gperf_snippet = run_command('sh', '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf, check: true)
114113
gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
115114
if cc.compiles(gperf_test)
116115
gperf_len_type = 'size_t'

0 commit comments

Comments
 (0)