Solved

bash and sh-compatibility

Posted on 2002-05-15
3
1,079 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
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 100 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

679 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