Skip to content

PR:2 Pass in a list of command args as the second bash argument and xargs #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

alanbacon
Copy link

(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\',']  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant