elixir-boilerplate icon indicating copy to clipboard operation
elixir-boilerplate copied to clipboard

boilerplate-setup.sh Linux limitation

Open byjpr opened this issue 4 years ago • 0 comments

Sed on MacOS and Linux behave a tiny bit different. -i '' works on MacOS, but will fail on Linux.

An example resolution that I'll paste-in-place here:

For support on both OSX and Linux, I use a simple if check to see if the bash script is running on OSX or Linux, and adjust the command's -i argument based on that.

if [[ "$OSTYPE" == "darwin"* ]]; then
  sed -i '' -e 's|$iconPath|images-theme-dark/$iconfile|g' "{}"
else
  sed -i -e 's|$iconPath|images-theme-dark/$iconfile|g' "{}"
fi

Source: https://stackoverflow.com/a/57766728

Based on the difference a viable solution might be to proxy the call to sed:

if [[ "$OSTYPE" == "darwin"* ]]; then
	sed_command = sed -i ''
else
	sed_command = sed -i
fi

byjpr avatar Dec 08 '20 11:12 byjpr