[colug-432] Portability of Shell Variable Substitution

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Wed Aug 10 09:15:43 EDT 2011


On Tue, 9 Aug 2011 20:50:06 -0400, Seth Hall <seth at icir.org> wrote:

> Of course, I think that using {} for string interpolation is 
> another bash-ism but you can do it other ways.

Uh oh, I thought that ${var} was a portable Bourneism. 
My main reference for Bourne shell is:

   Chapter 4
   The Bourne Shell 
   and Korn Shell
of
   UNIX in a Nutshell
   A Destop Quick Reference for System V & Solaris 2.0
   Copyright © 1986, 1992 O'Reilly & Associates, Inc. 
   Printing History
   June 1998: Minor corrections. New, complete index. 

In the "Variable Substitution" section on page 4-7, 
it has the following line: 

   ${var} Use value of var; braces are optional if var is separated. 

It notes which things are for Korn shell only, 
and the ${var} syntax is not noted as being a Kornism. 

Other chapters include: 

   Chapter 3 -- The UNIX Shell: An Overview
   Chapter 5 -- The C Shell

I have not seen any mention of bash in this book. 

What is the best reference others have found for the Bourne 
shell? As the name suggests, the nutshell book is not 
comprehensive. 

Back to Seth's sentence, what are those other ways of 
referencing a variable that is followed by letters? 




More information about the colug-432 mailing list