E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

What’s acceptable syntax in Unix and Linux sh scripts?

  • 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:

  1. In what flavor of /bin/sh are those scripts written?
  2. Can you suggest any references regarding writing portable (Bourne) shell scripts?
  3. 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!

What Do You Think?

 
37 queries / 0.381 seconds.