zero-trip foreach loops

Jean-Francois Lamy lamy at utai.UUCP
Mon Oct 6 04:53:30 AEST 1986


Is there an easy way to have csh foreach loops that don't complain if the
pattern given does not match any file, as may occur in the inner loop of this
bit of code:

foreach font (*.tfm)
    set fontname = `basename $font .tfm`
    foreach size ($fontname.*pxl)
    ...
    end
end

I've tried 

foreach size (`ls -1 $fontname.*pxl`).  

This stops the script from aborting, but still gives me the stupid 'No match'
message.  Gee, even FORTRAN does zero-trip DO loops these days...

Jean-Francois Lamy
AI Group, Dept of Computer Science     CSNet: lamy at ai.toronto.edu
University of Toronto		       EAN:   lamy at ai.toronto.cdn
Toronto, ON, Canada M5S 1A4	       UUCP:  lamy at utai.uucp



More information about the Comp.unix mailing list