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

sed commands are not portable #75

Open
jgosmann opened this issue Jan 2, 2020 · 3 comments
Open

sed commands are not portable #75

jgosmann opened this issue Jan 2, 2020 · 3 comments

Comments

@jgosmann
Copy link

jgosmann commented Jan 2, 2020

When running static.sh locally on macOS, the sed command fails:

sed: -e: No such file or directory

It seems that this is because the BSD sed does not accept multiple -e options, instead multiple commands have to passed to the same -e separated by ;. In addition, the BSD sed does not understand the -- to mark the following arguments as filenames.

@tbekolay
Copy link
Member

tbekolay commented Jan 2, 2020

As a workaround, you can brew install gnu-sed.

There doesn't seem to be a convenient alternative to sed that would be trivial to install on all machines (sd looks promising, but isn't packaged up for all environments). We might be able to replace the big sed command with many smaller sed commands, but that seems inefficient. Similarly, we might be able to replace it with multiple tr commands, but that's a maybe and would probably also be inefficient.

Since the main environment where this is an issue is Mac, and there's a straightforward way to use GNU sed on Mac, I'm inclined to not fix this unless you have a quick and painless fix.

@jgosmann
Copy link
Author

jgosmann commented Jan 2, 2020

I'd assume that the GNU version also supports chaining multiple commands with ; for a single -e option and the -- is not required at all.

@jgosmann
Copy link
Author

jgosmann commented Jan 3, 2020

I can confirm that

            sed -i \
                -e 's/# $/#/g; /get_ipython()/d; $ d' \
                "${nb_file%.ipynb}.py"

works with both BSD sed and GNU sed.

As for the workaround I'm not using brew, but MacPorts which installs GNU sed as gsed, so that the command is still not working without further steps. Bottom line, it is just easier to edit the script at the moment.

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

No branches or pull requests

2 participants