fab
fab copied to clipboard
Using shell in sub-processes
@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?