Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Opening a file for READing within script? (Last question today ;) )



I want to open a file given at the command line for reading by
associating it with a file descriptor number and then running

read -u 4 HEADERLINE
echo "Special header line behavior $HEADERLINE"

while read -u 4 DATALINE ; do
    echo $DATALINE
    sleep 1
done

I am doing this because I need to process the header differently than
the data, and I want the user to give the file name on the command
line rather than cat it into a pipeline.

Thanks!

(Oh -- my final FINAL sneaky question -- is there a way to
automagically associate the OPTS with an associative array?  like

optfill f:b OPTASSOC

modifying OPTASSOC to be {f->filename; b->EMPTY}, given command -b -f
filename; it would throw an error for required or non-standard opts
too, but not sure about good syntax ?  If there isn't, I will write
one, but not today ....
)



Messages sorted by: Reverse Date, Date, Thread, Author