Expr2.sed



#  Second-pass expression fixups:

#     Optimize expressions (for performance, not functionality) by
#     removing superfluous quoting and curly braces:

#     1. Inside ( ... ) expressions:

#           "${foo}"    -->   foo
#           "$foo"      -->   foo
#           "123"       -->   123

#     2. In @ (assignment statements):

#           ${foo}      -->   foo
#           $foo        -->   foo

#     3. Fixup earlier fixups that were looking for the end of a wordlist:

#           A[0] != ""  -->      A != ""

#     4. Fixup any assignments not already rewritten:

#           foo=...     -->      set foo=...

/^[^#]* (.*)/{
   s/"\${\([^}]*\)}"/\1/g
   s/"\$\([^"]*\)"/\1/g
   s/"\([1-9][0-9]*\)"/\1/g
   s/"0"/0/g
   }

/^[^#]*@ /{
   s/\${\([^}]*\)}/\1/g
   s/\$\([a-zA-Z0-9_]*\)/\1/g
   }

s/\[0\] != ""/ != ""/

/^[   ]*PATH=[^"]/{
   s/:/;/g
   s/=\(.*\)/="\1"/
   }
/^[   ]*[a-zA-Z][a-zA-Z0-9_]*[   ]*=/s/[a-zA-Z]/set &/



Hamilton C shell | Free Updates | Free Demo Software | Win32 Training
Y2K | Customer Testimonials | On-line Hamilton C shell User Guide
Home | Email | Support | Company Profile | Distributors | Links



Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number . This page was last modified August 14, 2001.