Closed parker-ldc closed 5 years ago
Hi, thank you very much for your contribution.
In general, I agree that we should support something like this.
Splitting the argument on spaces can be dangerous. Imagine something like map run 'cmd -s "hello world"
where the command would be split into
cmd
-s
"hello
world"
Better strategies might be:
map run du -hsc
or (if that causes problems) via map run -- du -hsc
. This way, the argument splitting would be done by the shell.Instead of adding an additional runq
command, I would rather like to use something like map run -q
or map -q run
. The -q
/--quiet
option could be useful for other commands as well.
What do you think?
You're right about the whitespace issue. Also, my patch was a quicky fix to handle something I was working on and wasn't particularly well thought out.
I've subsequently had a bit of time to delve into the problems I've seen and think I can come up some tests/test cases to demonstrate the issue (and maybe to see if it's just me/my environment), as well as a fix for them.
Sorry to take up your time like this, but I do appreciate the welcoming attitude.
This PR updates the
run
function to split the command on whitespace before runningsubprocess.call
, so it can have have options/parameters specified, e.g.:ls | map run 'du -hsc'
it also adds a variant of the
run
function,runq
, which doesn't print anything about what it's doing (because I'm too lazy to parse it out of the command output)