Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

bash and sh-compatibility

Posted on 2002-05-15
3
Medium Priority
?
1,096 Views
Last Modified: 2008-01-16
bash claims to be sh-compatible in it's man-page. This seems to be wrong:

     echo 1>file
and
     echo 0>file
and
     # as many other examples as you like ..

is valid sh syntax.

Does somebody know how to tell bash to be sh-compatible?
Or is there a free (GPL or whatever) sh for Linux?
0
Comment
Question by:ahoffmann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 400 total points
ID: 7012396
If you are talking about the differences with using echo under sh vs echo under bash then you aren't actually talking about shell incompatiblity. In some implementations of sh echo is a built in and in other's it isn't. Furthermore, each system seems to have a different idea of exactly what echo does and how it behaves. If you examine very many spohisticated multi-platform scripts (or try to write same) you'll find that they frequently go to a lot of trouble to figure out what flavor of echo is available.

I'd be interested in places that you see incompatibility that  only involve the standard Bourne shell commands.
0
 
LVL 51

Author Comment

by:ahoffmann
ID: 7012505
damn, should have thought about built in echo, 'cause I'm used to some other dragons with it too ;-)

Anyway it behaves equal in both: bash and sh (Solaris, didn't check carefully)

> I'd be interested in places that you see incompatibility that  only involve the standard Bourne shell commands
see : command
0
 
LVL 40

Expert Comment

by:jlevie
ID: 7012828
Personally I've never found any cases of valid Bourne shell syntax that Bash wouldn't execute, assuming that builtin vs not-builtin aren't an issue. The reverse is not true. Bash has some features (e.g., export, etc) that Bourne shell doesn't.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question