I occasionally do work on an older Solaris machine whose default version of grep
is non-POSIX-compliant. This causes problems in my rc files because the default grep
on the machine doesn't support the options I need.
This is a machine at my place of work, and I'm not an admin; so I can't just install newer/better versions of commands as I see fit. However, I notice that the machine does have a suitable XPG version of grep
at /usr/xpg4/bin/grep
.
Obviously, I can solve the problem (for Solaris) in my rc files with:
alias grep='/usr/xpg4/bin/grep'
But what about machines where this isn't necessary? My goal is to have a single rc file for each shell that I can drop into any Unix-like system and have it just work.
This got me thinking...
- Is there ever a case where I wouldn't want to use the XPG version of a command?
- If so, when?
- Couldn't I just blindly add
/usr/xpg4/bin/
to the beginning of$PATH
in my rc files on all machines and forgo aliasing individual commands to their XPG* versions?- Or will this cause problems for some commands?
- Is it the case that
/usr/xpg4/bin/
exists only on machines where it is "necessary"?- I ask because I notice that
/usr/xpg4/bin/
doesn't exist on my Ubuntu machine.
- I ask because I notice that
So to sum up, is this a good a idea?
if [ -d "/usr/xpg4/bin" ]; then
#Place XPG directory at beginning of path to always use XPG version of commands
export PATH="/usr/xpg4/bin:$PATH"
fi
If not, why not?