Hamilton LaboratoriesHamilton C shell 2012User guideSamplessh2csh.csh

loop.sed

Oregon Coast

loop.sed
Previous | Next

#  Fixup for, while and until statements.
#  Copyright (c) 1992-2012 by Hamilton Laboratories.  All rights reserved.

#     for i in wordlist          foreach i ( wordlist )
#     do                   -->
#        :                          :
#     done                       end

#     while list                 while ({ list })
#     do                   -->
#        :                          :
#     done                       end

#     until list                 while (! { list })
#     do                   -->
#        :                          :
#     done                       end

/^[   ]*for.*;[   ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*while.*;[    ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*until.*;[    ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*for/s/for[   ]*\([^   ][^   ]*\)[    ]*in[    ]*\([^   ].*\)$/foreach \1 (\2)/
/^[   ]*while/s/while[  ]*\([^(  ].*\)$/while ({ \1 })/
/^[   ]*until/s/until[  ]*\([^(  ].*\)$/while (! { \1 })/
/^[   ]*do$/d
/^[   ]*done/s/done/end/

Previous | Next