From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29457 invoked from network); 19 Oct 2004 13:05:18 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Oct 2004 13:05:18 -0000 Received: (qmail 13596 invoked from network); 19 Oct 2004 13:05:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Oct 2004 13:05:12 -0000 Received: (qmail 9933 invoked by alias); 19 Oct 2004 13:04:26 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8074 Received: (qmail 9914 invoked from network); 19 Oct 2004 13:04:24 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 19 Oct 2004 13:04:24 -0000 Received: (qmail 12220 invoked from network); 19 Oct 2004 13:04:23 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 19 Oct 2004 13:04:20 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i9JD4Iv17527 for ; Tue, 19 Oct 2004 13:04:18 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id ; Tue, 19 Oct 2004 14:03:12 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 19 Oct 2004 14:07:00 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i9JD4DIj025043; Tue, 19 Oct 2004 14:04:14 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i9JD46qt025040; Tue, 19 Oct 2004 14:04:13 +0100 Message-Id: <200410191304.i9JD46qt025040@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Nikolai Weibull cc: zsh-users@sunsite.dk Subject: Re: Redirection and Variables In-reply-to: <20041019120220.GA9258@puritan.pcp.ath.cx> References: <20041019120220.GA9258@puritan.pcp.ath.cx> Date: Tue, 19 Oct 2004 14:04:05 +0100 From: Peter Stephenson X-OriginalArrivalTime: 19 Oct 2004 13:07:00.0915 (UTC) FILETIME=[856CD030:01C4B5DC] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 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 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 **********************************************************************