Sun was so into keeping backward compatibility intact they would not update the default /bin/sh because of some compatibility issues that could affect customers. So they included the newer XPG4 sh in a different location (it is a POSIX-compliant ksh88): /usr/xpg4/bin/sh. So you can write:
#!/usr/bin/env sh
So that users who have setup PATH=/usr/xpg4/bin:$PATH get the correct shell and everything works fine.
Re:SSH Tricks
by JoshTriplett on Monday September 19, 2011 @10:01PM
(#3015963)
No, I'm not looking to fork and exec a second program, and short of busybox most shells don't have basename built in.
Common idiom, works in POSIX /bin/sh, bash, dash, ash, and every other sh I've encountered. I make a point of avoiding bashisms in /bin/sh scripts, but I have no problem counting on POSIX sh. :)
Here's how to work around it:
FWIW it's a little easier to read, too.