Suppose I want to run something like ls a* using plumbum.
from plumbum.cmd import ls
ls['a*']()
...
ProcessExecutionError: Command line: ['/bin/ls', 'a*']
Exit code: 1
Stderr: | ls: a*: No such file or directory
I understand plumbum automatically escapes the arguments, which is usually a good thing. But is there a way to make it understand glob expressions should be passed to the shell as-is?
plumbumpassesa*tolscommand as-is.lscommand doesn't run any shell, so there is no glob expansion (it is done by the shell on *nix).You could use
globmodule to do the expansion:Another way is to use
Workdirobject:To defer the call; you could use
ls['-l'][args]syntax (note: there is probably a bug inplumbum 1.1.0version that requires to convertargslist to a tuple explicitly).If you want; you could call the shell:
Note: Python's
glob.glob()function might produce the glob expansion different from that of the shell.