Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Redirection and Variables
- X-seq: zsh-users 8074
- From: Peter Stephenson <pws@xxxxxxx>
- To: Nikolai Weibull <zsh-users-list@xxxxxxxxxxxxx>
- Subject: Re: Redirection and Variables
- Date: Tue, 19 Oct 2004 14:04:05 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20041019120220.GA9258@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20041019120220.GA9258@xxxxxxxxxxxxxxxxxx>
Nikolai Weibull wrote:
> A couple of questions:
>
> Is this the simplest way to do the following?
>
> local -A http_programs https_programs mailto_programs ftp_programs
>
> http_programs=(xw "/usr/bin/firefox -remote 'openURL(%s, new-tab)'"
> xt "/usr/bin/elinks '%s'")
> http_programs=(xw "/usr/bin/firefox -remote 'openURL(%s, new-tab)'"
> xt "/usr/bin/elinks '%s'")
> mailto_programs=(xt "/usr/bin/mutt '%s'")
> ftp_programs=(xt "/usr/bin/lftp")
>
> lookup () {
> echo "${(P)$(echo ${1}_programs\[xw\])}"
> }
Using eval would be nicer than the $(...), but actually there's a hack
to avoid even that:
lookup() {
echo ${(P)${:-$1_programs[xw]}}
}
The empty nested substitution always returns the string after the :-,
which undergoes expansion, so the (P) flag can operate on that.
> If I have the following in a script that reads input from stdin:
>
> sed -n "s/$REGEX/\1\n/gp" <&0 | sed "/$REGEX/!d" > $TMP
> if [[ ! -s $TMP ]]; then
> rm -f $TMP
> exit 1
> fi
> ${EDITOR:-vi} $TMP
>
> my $EDITOR (vim) will complain that
> "Vim: Warning: Input is not from a terminal". Is there a simple way to
> get around this?
Are you saying the early part is important, i.e. if you just run vi in
the script without the earlier bit it works? That sounds unlikely,
although I haven't investigated in detail. If that's not the case, you
probably need to do some direction to force vi to use /dev/tty.
I'm not sure why you have "<&0", that simply redirects standard input
from standard input.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author