Skip to content
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

GNU/BSD sed compatibility #12

Closed
ryanmjacobs opened this issue Mar 5, 2015 · 6 comments
Closed

GNU/BSD sed compatibility #12

ryanmjacobs opened this issue Mar 5, 2015 · 6 comments

Comments

@ryanmjacobs
Copy link
Owner

We need a command that doesn't require gnu-sed to be installed with brew.

This should work on both GNU and BSD systems:

$ cat > file.c
#!/usr/bin/c blah blah blah
^D
$ sed -i.bak '1!b;s/^#!/\/\/#!/' file.c
$ cat file.c
//#!/usr/bin/c blah blah blah

However, I don't have access to a BSD system...
It works just fine on GNU. Can someone confirm that it works on BSD systems, too? Thanks.

@alistairking
Copy link
Contributor

That fails for me on FreeBSD:

alistair@loki:~$ cat > file.c
#!/usr/bin/c blah blah blah
alistair@loki:~$ sed -i.bak '1!b;s/^#!/\/\/#!/' file.c
sed: 1: "1!b;s/^#!/\/\/#!/": undefined label ';s/^#!/\/\/#!/'

@lukaf
Copy link

lukaf commented Mar 5, 2015

Since only the first line is considered, this works (also tested on FreeBSD).

$ cat file.c
#!/usr/bin/c blah blah blah
$ sed -i.bak '1,1s/^#!/\/\/#!/' file.c
$ cat file.c
//#!/usr/bin/c blah blah blah
$ 

@alistairking
Copy link
Contributor

Yep, that works for me!
(also tested on OSX Mavericks.)

@ryanmjacobs
Copy link
Owner Author

@lukaf Cool that works for GNU, too! I'll use that later today. Then, we should be able to get a homebrew package going.

ryanmjacobs pushed a commit that referenced this issue Mar 6, 2015
@ryanmjacobs
Copy link
Owner Author

Okay, I've merged in this change. Can someone try using the new script?

@ryanmjacobs
Copy link
Owner Author

I have removed sed completely by using tail instead. We shouldn't have these compatibility issues any more.

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

No branches or pull requests

3 participants