From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21118 invoked by alias); 31 Mar 2010 15:12:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27850 Received: (qmail 24827 invoked from network); 31 Mar 2010 15:12:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <100331081153.ZM2688@torch.brasslantern.com> Date: Wed, 31 Mar 2010 08:11:53 -0700 In-reply-to: <20100331060602.GA91691@redoubt.spodhuis.org> Comments: In reply to Phil Pennock "Re: Is this a bug? Why not?" (Mar 30, 11:06pm) References: <100330224612.ZM1818@torch.brasslantern.com> <20100331060602.GA91691@redoubt.spodhuis.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Is this a bug? Why not? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Incidentally, this came up because of a discussion on the POSIX standards mailing list (austin-group) in which David Korn just asserted that he'd like to add the syntax ${"var"} which means to expand the value of var as if it's quoted (what zsh's normal mode does all the time). This differs from "${var}" because you can write ${"var"-*} and get the value of $var quoted but the glob pattern unquoted. Apparently the old Bourne shell allows the abominable "${var"-*} (note quote placement overlapping with brace placement) to accomplish this. I was hoping to be able to say "Oh, zsh already has syntax XYZ for that" but in fact we don't -- zsh either always, or never, does it, depending on the globsubst option; there's no way to flip globsubst on the fly. On Mar 30, 11:06pm, Phil Pennock wrote: } Subject: Re: Is this a bug? Why not? } } So the string ${var} when treated as a variable-name is empty but } defined? The four expansions with a nested ${var} are entirely } consistent with the behaviour when expanding a variable which is } defined with a value of length 0. } } Seems unusual, but consistent. Indeed. OK, I can live with that, as it's been that way forever. } In bash, ksh, bad substitution. In ksh93, it gets weird: } $ echo ${var-???} } OSM SCM bin dbg doc etc lib man src tmp www } $ echo ${${var}-???} } ksh93: syntax error: `!' unexpected That is weird, but AFAIK only zsh of all shells allows wrapping ${...} in another ${...} as valid syntax, so this may just be an error ksh93 didn't catch. } The ksh reference-name expansion made me think of the somewhat opposite } expansion in zsh, (P)var ... } } Hrm, zsh 4.3.10 1.4705: } } % print ${(P)-???} } zsh: 0239BCJPXZgiklms: ?? } } Strange that the first entry is somehow tying into expanding $- for the } shell options ... Actually that makes perfect sense; only the :- and :+ forms are doc'd as working with a missing parameter name, so ${(P)-} really does mean to grab the value of $- and try to use that as a parameter name. It otherwise has to behave like ${-?string}.