tips
                                
                                 tips copied to clipboard
                                
                                    tips copied to clipboard
                            
                            
                            
                        Make xargs commands less dangerous
Make xargs commands less dangerous
I think this is problematic because xargs does not seem to automatically eat the leading whitespace on each line if you specify the delimiter. Perhaps a more comprehensive solution would be to use the -Z parameter with grep, and eat leading whitespaces after each null in the result of that, before finally passing to xargs with -0? Just a thought.
For example, the current PR revision would do this on my end:
$ git branch --merged master | grep -v '^\*' | xargs -d '\n' -n 1 git branch -d
error: branch '  test1' not found.
error: branch '  test2' not found.
Reasonable, @echuber2.
grep -Z is on OSX (bsd grep) is shorthand for grep --decompress which is not the gnu grep -Z/--null functionality we're aiming for.  I think the simplest solution here would be piping  ... | sed  's/^ \+//g' | ... after the grep and before the xargs.
Thoughts?
I've updated the pull request.
This seems to be duplicating the default behavior (pre-request). Perhaps I'm misunderstanding what this is meant to do? (By the way, I tried a variation with grep --null and it seems that it does not work together with -v, for some reason. The result will still be delimited with newlines.)