Make subprocess.Popen call shell-agnostic
The shell command type -p npm
is valid in bash
but the -p
option is not valid in sh
or dash
(the default shell - rather than 'login shell' - in many Linux).
However, type npm
gives the same result in all three shells: "npm is /usr/bin/npm"
; so taking the last word from that result should give us what we need.
https://yourlabs.io/oss/djsnowpack/-/blob/master/djsnowpack.py#L56-62
It is possible to specify /bin/bash
as the required shell using the executable
keyword, but the shell may not be installed in the environment. The same argument applies to using the command which
.
https://docs.python.org/3/library/subprocess.html#popen-constructor