Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I wanted to know whether scripts written for dash, ash, and sh are 100% compatible?

Are there any added features to dash or ash, or syntax change?

From what I heard, ash is a direct descendant of sh.

share|improve this question
    
ash is a striped down form of bash –  Joe Aug 7 '12 at 6:14
1  
Source? I saw nothing that said that ash is related to bash –  user1115057 Aug 7 '12 at 6:25
    
Why wouldn't people just submit patches to bash instead of creating all kinds of shells, that buffles me all the time. If you really want to know, read the manual, e.g man ash –  warl0ck Aug 7 '12 at 6:36
2  
Correct, it's not descendant from bash. It would be more precise to say they're descendant from sh (the original Bourne shell), but that's not fully correct either. –  Zlatko Aug 7 '12 at 6:37
    
You can use the utility checkbashisms to test that your script is POSIX compliant. –  donothingsuccessfully Aug 7 '12 at 17:37
add comment

1 Answer

The short answer is no, they're not 100% compatible.

But most the shells are pretty close to the basic, so you would only rarely bump into inconsistencies. In fact, most shells differ not much by added syntax, but by some extra features like tab-completion and similar.

Also, dash is sort of a descendant of ash - or port from BSD to linux, to be precise. And all of them should be descendants or different implementations of sh. In fact, sh is on most systems just a symlink to bash, dash or something else. What matters is POSIX compliance - and when you write scripts according to standards, you won't run into problems.

The difference between those shells is in optimizations and performance. They're less feature-rich then bash, but they are fully legitimate shells. Bash is feature-rich for interactive work, but uses more memory, for example.

share|improve this answer
    
But for script usage, they are compatible? –  user1115057 Aug 7 '12 at 6:36
    
And about the POSIX compliance, even if I follow that standard, if a script is written for Bash, I dont think it will run on any sh or its descendant –  user1115057 Aug 7 '12 at 6:37
    
They should be compatible with each other if you're not using some obscure features. But if you use bash script, you might run into more troubles. –  Zlatko Aug 7 '12 at 6:41
    
never intended to use bash with sh or ash or dash. What are those obscure feature? –  user1115057 Aug 7 '12 at 6:42
    
I do not think ash is POSIX compliant but do not quote me on that –  Joe Aug 7 '12 at 7:21
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.