Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substitution Cruft
- X-seq: zsh-users 6560
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Substitution Cruft
- Date: Wed, 10 Sep 2003 14:31:49 +0000
- In-reply-to: <20030910132129.GE3743@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030910132129.GE3743@xxxxxxxxxxxxxxxxxx>
On Sep 10, 3:21pm, Nikolai Weibull wrote:
}
} lprec ${(Q)${(zf)$(sed -n 's/["\$]/\\&/g;s/^\([A-Za-z]\+\)=\(.\+\)$/--\L\1\E "\2"/;/^--[a-z-]\+/p' < $tmp)}} &
} Is there a simpler way than using ${(Q)${(zf)...}}?
Without eliminating the $(sed ...) the best alternative is:
eval lprec "$(sed ...)"
(Yes, the double quote in ["\$] is handled correctly even if you wrap the
whole $(...) in double quotes.)
The whole thing could be replaced (assuming default setopts shwordsplit
et al.) with:
while read option value
do arguments=( $arguments --${(L)option:s/://} $value )
done < $tmp
lprec $arguments &
which while it takes a few more lines is certainly less cryptic and does
not fork a process. If for some reason you must write it as one line:
while read o v; do a=($a --${(L)o:s/://} $v); done < $tmp; lprec $a &
Even if you stick "local -a a; local o v;" on the front of that, it's
shorter than what you started with.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author