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

Solaris 11 compatibility #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agkozak
Copy link

@agkozak agkozak commented Dec 18, 2017

z requires a version of awk that has the -v option. Solaris 11 uses by default an antiquated version of awk that does not have that option. Its nawk does have -v, however. I propose adding the function

awk() {
    case $(uname -a) in
       SunOS*) nawk "$@" ;;
       *) command awk "$@" ;;
    esac
}

It simply redirects calls on awk to nawk on Solaris and should have no effect on other systems. I have tested it with both bash and zsh.

@agkozak
Copy link
Author

agkozak commented Dec 18, 2017

An even better idea: only run uname once, when the script is sourced, and only define the awk() function on Solaris:

case $(uname -a) in
  SunOS*) awk() { nawk "$@"; } ;;
esac

@agkozak
Copy link
Author

agkozak commented Jan 23, 2018

fasd's method seems even better: pick an available version of awk that supports the -v option, assign it to $_Z_AWK, and use that instead of calling on awk.

@agkozak agkozak changed the title Solaris 11 compatibility (uses nawk) Solaris 11 compatibility Jul 28, 2018
@agkozak
Copy link
Author

agkozak commented Jul 28, 2018

Solaris sed lacks the -i option, so the z -x command won't work. We have to use a temporary file.

@rupa
Copy link
Owner

rupa commented Sep 11, 2018

i kinda suck at github flow - could you squash these commits so I can get a better look at them?

@agkozak
Copy link
Author

agkozak commented Sep 11, 2018

@rupa Done!

Copy link

@dmd dmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional complexity seems iffy considering the userbase of Solaris 11.

@agkozak
Copy link
Author

agkozak commented Oct 25, 2019

I think it would be a shame to give up on POSIX compliance (sed -i isn't in the standard) and having the script work on a genuine Unix distribution (whose default awk might be old enough not to have awk -v -- but another version of awk, such as nawk, will have it). If there's a simpler solution, I'm all for it -- but my fixes do work.

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

Successfully merging this pull request may close these issues.

3 participants