Solved

bash and sh-compatibility

Posted on 2002-05-15
3
1,077 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bash script - Exit out of choice loop 2 44
AWS EC2 HTTP & HTTPS 2 45
SMB share across internet 15 65
Using Linux to replace Windows Server 2008 R2 for network drives 5 107
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

832 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