Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Next: , Previous: Assignments, Up: Portable Shell

10.7 Parentheses in Shell Scripts

Beware of two opening parentheses in a row, as some shell implementations mishandle them. For example, ‘pdksh’ 5.2.14 misparses the following code:

     if ((true) || false); then
       echo ok
     fi

To work around this problem, insert a space between the two opening parentheses. There is a similar problem and workaround with ‘$((’; see Shell Substitutions.

Posix requires support for case patterns with opening parentheses like this:

     case $file_name in
     (*.c) echo "C source code";;
     esac

but the ( in this example is not portable to many older Bourne shell implementations. It can be omitted safely.


 
 
  Published under the terms of the GNU General Public License Design by Interspire