Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Speaking of sh and bash...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Speaking of sh and bash...
Authored by: cynikal on May 12, '04 07:52:15PM

Am I the only one bothered when you see a unix system with a bash in sh's clothing? Meaning there's a bash in place of sh?

Yes I love my bash and prefer it to sh, but it tends to spoil you if you don't have the real sh available..

It might not be a big deal if you are only on systems using these faux sh's. But what about when you write a shell script and you think it's a sh syntas but you end up being used to bash syntax instead? Guess what, when it's distributed, it's not compatible on systems with a real "sh"! I've ran into countless people's "sh" scripts that use bash's $(..) command substitution expansion and it breaks things. (this is just one example on the difference in syntax).

People, please don't write bash scripts and pass em off as sh scripts.. There _IS_ a difference and the real sh is not forwards compatible to bash! Please check your syntax before claiming it's a sh-compatible script!!



[ Reply to This | # ]
Speaking of sh and bash...
Authored by: red6rick on May 12, '04 08:08:10PM

If you read the man page for bash, you'll find that it behaves differently when invoked as "sh" than when invoked as "bash". The behavior in "sh" invocation closely mimics the original sh.



[ Reply to This | # ]
Speaking of sh and bash...
Authored by: cynikal on May 13, '04 07:27:02PM

*sigh*.. fyi, i've rtfm before, have you?

if you paid more attention to what I wrote:

==<cynikal@cynsys>-<ttyp2>-<1919:50>==
--[~]-- $ sh
sh-2.05b$ ls -ld $(pwd)
drwxr-xr-x 49 cynikal cynikal 1666 13 May 00:32 /Users/cynikal/

this is NOT SH SYNTAX!!! it's BASH ONLY syntax.. with sh, only ls -ld `pwd` should work!

My original point is that people don't bother checking their scripts compatibility on systems with real sh's such as Solaris.. and please don't point me to /usr/xpg4/bin/sh, i don't want to have to modify all these broken scripts.



[ Reply to This | # ]
Speaking of sh and bash...
Authored by: LC on May 16, '04 04:13:59PM

I recall AIX utilizing a ksh as sh; I recall HP-UX providing restricted and Bourne or sh-Posix modes.
I believe that the Posix specs probably define what sh is required to do and that it's not specifically Bourne.
What era are we concerned with ... UNIX95, UNIX98, X/Open etc. Larry.



[ Reply to This | # ]