Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Opening a file for READing within script? (Last question today ;) )
- X-seq: zsh-users 13579
- From: Michael Hernandez <sequethin@xxxxxxxxx>
- To: Webb Sprague <webb.sprague@xxxxxxxxx>
- Subject: Re: Opening a file for READing within script? (Last question today ;) )
- Date: Wed, 10 Dec 2008 12:42:04 -0500
- Cc: zsh-users@xxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=gqqF6sOpMYb7VNZBeQAHYsTiyOhiGe++07l3PTNLmjQ=; b=vhnfhqXunzMZqKjqiV21KuQlnRVSeYetKq3Sc98LHnlU5ZwsYiuEFbTEqoR48b+r40 030r5CyD/E/TlzNOqEXFQb6j+XJGSDJRYLuUmYKjvqd/tKqMM12kew2eCfBBitY4Sh7a 47Pp1o+9I55heNrPpG5AYlQu51Z27H1F1uH+U=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=OYFj+VTNwzEqdN3QmnoCYRAnv5+kEulSP1XsUtk5c/3cN7HWO+p7G4LWoPeo2w0Vyb 0iF+zfjG3aCaFIq/eFO/Gsaxn4sXZfonKyzX4ZS4SNS7f0LtyrHMEbiMEerQcGYXlpPs wVko1lwPiAL/MWh9PdClxGS/9p5BbMtQYBNAY=
- In-reply-to: <b11ea23c0812100934t1b629671y6b284bfb359e5e52@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0812100934t1b629671y6b284bfb359e5e52@xxxxxxxxxxxxxx>
On Dec 10, 2008, at 12:34 PM, Webb Sprague wrote:
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 ....
)
Not sure about your first question but as for your final sneaky
question...
given options (via a function call or call to your script, etc), the
line
zparseopts -D -E -A opts f: b:
when inside your function,
will take the positional parameters and add the options f and b to the
associative array named opts so that:
call_my_function -f FVAL -b BVAL
$opts[-f] will be equal to FVAL
$opts[-b] will be equal to BVAL
check out man zshmodules and look for zparseopts in there for the
details on that
--Mike H
Messages sorted by:
Reverse Date,
Date,
Thread,
Author