-
Notifications
You must be signed in to change notification settings - Fork 0
make terraform-fmt.sh work without gsed #3
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
Conversation
not all macOS users have gsed installed, so we need to just do the BSD-flavored `sed` incantation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am using macOS, but my sed command comes from nix and is the GNU variant.
so this would break for me in this case.
i guess you would need to check something like sed --help | grep GNU to either be a 0 or error out to be sure which one you have.
In this case i wonder though if this should not work for both variants
sed -i -E '/^$/N;/^\n$/D' the lowercase -i works the same on both variants and the capital -E should as well
it exists in both variants, but behaves differently in both variants. see https://stackoverflow.com/a/4247319/138757. i am considering moving to perl then, but you're right, the also... never thought about nix! thanks for adding that perspective @sbresin |
|
One more thing. I will move to uutils-coreutils soon and ubuntu for example is planning to do as well. So theres even one player more, even though this one ist GNU compatible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are writing to the file using redirection you could have just used sed without the -i flag. But i am fine with it either way
|
general note here: in the future we just have to balance when it's ok to tell people "you need gsed on a mac", compared to how many hoops we want to jump through to make it work with BSD |
oh yeah. duh. 🙄 🤦 |
not all macOS users have
gsedinstalled, so we need to just do the BSD-flavoredsedincantationUPDATE: or maybe
awkgets rid of some cross-platform jank...❗ needs testing on macOS!