bash
bash copied to clipboard
PR:2 Pass in a list of command args as the second bash argument and xargs
(includes PR:1, can be merged instead of PR:1)
The passed in list will be checked for correctness, unpacked and appended to the orginal command
From updated readme:
Pass in arguments as an array::
>>> bash('ls', ['.'])
bash.pyc
tests.pyc
Because arguments can now be passed in as a list and because we can get the results of the previous call as a list: we can implement the xargs
function. Where the results of the previous call are mapped onto the next function:
>>> bash('ls').bash('grep "\.py"').xargs('grep "author=\'Alex Couper\'"')
'setup.py: author=\'Alex Couper\','
Which is similar to, but not exactly the same as (due to how grep works):
>>> results = [f for f in bash('ls').bash('grep "\.py"')]
>>> list(map(
lambda f: [f, bash('grep "author=\'Alex Couper\'"' + f)]
))
[ [''setup.py', ' author=\'Alex Couper\','] ]