From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13180 invoked by alias); 6 Sep 2014 19:34:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19056 Received: (qmail 12261 invoked from network); 6 Sep 2014 19:34:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140906123433.ZM20433@torch.brasslantern.com> Date: Sat, 06 Sep 2014 12:34:33 -0700 In-reply-to: <20140906184749.GR4075@isis.sigpipe.cz> Comments: In reply to Roman Neuhauser "set -o nounset; foo=(); print ${foo:#bar}" (Sep 6, 8:47pm) References: <20140906184749.GR4075@isis.sigpipe.cz> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Roman Neuhauser , zsh-users@zsh.org Subject: Re: set -o nounset; foo=(); print ${foo:#bar} MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 6, 8:47pm, Roman Neuhauser wrote: } } roman@wrench ~ 0 1078 0 > print ${foo:#bar} } zsh: foo: parameter not set } roman@wrench ~ 0 1079 1 > } } the problematic part is ${foo:#bar} triggering nounset. FMPOV it *is* } set (but null), so i'd say the observed behavior is a bug. This seems to be ${name:#word} being confused with ${name:?word} where the ":" means to treat an empty parameter as unset. This also affects the newer ${name:^word} form. } is it fixable? I don't immediately see a simple code change that would do so, but I'm sure it can eventually be fixed. } or is there at least a good workaround? (stuffing the } array with a sentry is not a good workaround.) You can use ${foo##bar(#e)} with extendedglob, I think, but it may depend on context. Without extendedglob I don't see a good way.