Coder Social home page Coder Social logo

Fix sed on MacOS about crpgp HOT 1 CLOSED

OmarElawady avatar OmarElawady commented on August 16, 2024
Fix sed on MacOS

from crpgp.

Comments (1)

sameh-farouk avatar sameh-farouk commented on August 16, 2024

macOS uses the BSD version of sed, which differs in many respects from the GNU sed version that comes with Linux distros.
If you need to support BOTH platforms, there are two solutions:
1- restrict your sed scripts to what BSD sed supports, they will generally work in GNU sed too - with the notable exception of using platform-specific extended regex features with -E.
checking current sed script, I can spot these Incompatible features:

  • Use of the -i option without an argument (in-place updating without backup) is incompatible. in BSD sed it MUST use -i '' which won't work on GNU sed. This can be easily adapted to work on both platforms, e.g, using a backup)
  • OS X's sed / BSD sed doesn't support -z (--null-data).
  • The BSD implementation of sed additionally does not support \b as a word boundary pattern. it uses [[:<:]] and [[:>:]] instead.
  • \n will be treated literally within a replacement string.

it may be possible but it is a headache to find a syntax that would run flawlessly on both platforms, in the meantime, there is an easier solution.

2- the other option is to use homebrew to install GNU version of sed for MacOS

brew install gnu-sed
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"

then it would work just fine as it works on Linux, tested. running make runv would succeed in macOS 10.15 after installing gnu-sed. note that the commands above add gnu-sed to PATH only temporally to make it the default sed command so you can run the make scripts. closing the shell have the effect of restoring BSD sed as the default one.

Screen Shot 2022-02-23 at 7 18 23 PM

from crpgp.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.