Created
October 30, 2014 04:02
-
-
Save steveklabnik/91ff182a4da80271cda5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| for name in $(cat repos.txt); do | |
| echo $name; | |
| repo=$(echo $name | cut -d'/' -f2); | |
| echo $repo; | |
| hub clone $name; | |
| cd $repo; | |
| hub fork; | |
| pwd && grep -lZR 'panic!' . | xargs -0 -l sed -i -e 's/panic!/panic!/g'; | |
| git add -A; | |
| git commit -m 'fail -> panic'; | |
| hub pull-request -m <<-EOM fail -> panic | |
| Sorry I broke your code with rust-lang/rust#17894 ! Here's a fix :heart: | |
| (this is a semi-automatic PR, so sorry if it's not perfect. Let me know and I'll fix any problems.)' | |
| EOM | |
| cd ..; | |
| done |
I find in bash I always have issues using ! without escaping it on the terminal line. Is it possible your xargs is getting tripped up on the ! ?
@steveklabnik - when you say the sed works fine, are you talking about the sed part only or the whole of line 10? I'm wondering if it's xargs failing and/or quoting issues inside a bash script vs. command line (as @mgpcoe notes above)
I ran the script with set -e (to stop on error) and set -x (to show output as executed).
The relevant bit of output (OS X):
+ grep -lZR 'panic!' .
+ xargs -0 -l sed -i -e 's/panic!/panic!/g'
xargs: illegal option -- l
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
My xargs (OS X) doesn't have a -l (and the GNU man page says -l is deprecated anyway). I switched it out for -L 1 and that line completes (and instead has problems with "nothing to commit" after replacing panic with panic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, then that's a GNU vs BSD thing.