What’s acceptable syntax in Unix and Linux sh scripts?
- 0
- Add a Comment
- No Related Post
Dave, I ran across your sites and Wicked Cool Shell Scripts book while trying to convince myself that `sleep 0` is a valid and relatively portable command to use freely in my unix shell scripts.
I looked at a few of the Bourne shell scripts and they seem to use constructs like $( … ) and $(( … )) which are not standard Bourne shell (to my understanding). So I actually have three questions, rather than just one:
- In what flavor of /bin/sh are those scripts written?
- Can you suggest any references regarding writing portable (Bourne) shell scripts?
- I would love to find an equivalent reference for what unix utilities *and options* to use for increasing script portability. Any suggestions?
Well, this is a bonus shell scripting question, I’d say! I think that the first thing to realize is that the Posix standard for the “sh” shell includes a number of structures and constructs that are still not fully supported in some commercial Unixes (in particular Solaris 9’s default /bin/sh isn’t Posix compliant).
According to Posix’s sh man page, the $( ) notation is…
Continue reading at Ask Dave Taylor!
