fab icon indicating copy to clipboard operation
fab copied to clipboard

Using shell in sub-processes

Open hiker opened this issue 5 months ago • 0 comments

@MatthewHambley , while working on some linker improvements, we realised that it would be convenient to use shell syntax in some compiler- and linker-flags, e.g.:

mpif90 ... $(nf-config --fflags) $(nf-config --flibs)

ATM this doesn't work, because when we call subprocess.run, we don't request a shell to be used.

While it is easy enough to fix that (use " ". join(command), and add shell=True), there is a change in the semantics: atm, any space in a parameter (which is part of the command-list) would need to be enclosed in quotes).

A quick test seems to indicate that we can just quote ALL comment entries, e.g.:

subprocess.run('"git" "--version"', shell=True)
subprocess.run('"git" "$(echo --version)"', shell=True)

works just fine. But I am worried about this change, e.g. are there any other side-effects that I am missing?

hiker avatar Sep 23 '24 02:09 hiker