From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12344 invoked by alias); 10 Apr 2015 02:06:04 -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: 20123 Received: (qmail 11537 invoked from network); 10 Apr 2015 02:06:02 -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=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=93wZh17uJEhOq6uc1+z9gGDpYcVpxUPTOsRVz9w1sUU=; b=QANAnzMYoQVM0hu9tIyEyJuoOhRqcFcO5j5RAVALclbl3pLHtvyjpBM1XgmbuzNzB1 iocf5jRXumHepgxt8Gc4UqgBGzP4AlHueviwti5mD1rYguYGadw+gX+ePCri8y7GxwJr 4ONIRQ8pqzLpX5bLosXxLmmFbT6GKmnmeB3YXYtoj0mPjASMZBDUWflcLLlMObsaB6jv LNt5ds3ARUWi53Jg1KK9QoswBEVOeh9q1UhZmUE/t6Ijs9GDscPGpy3tE5iqIc5dYWEX B+rCSBhpprRbucoyuTELJFHY0SyPoKgTsO6kZzAk2lCBgkHVka7Wn7+I9H2uzH+kXfQG tahg== X-Gm-Message-State: ALoCoQnrFErSgXJ0Dvlob502GzCReHBl8qPS0tmP2F0ZB8txU/uzY9Jgk/ghRCw9g00Jk+wZJ1QD MIME-Version: 1.0 X-Received: by 10.152.22.104 with SMTP id c8mr7019965laf.87.1428631559122; Thu, 09 Apr 2015 19:05:59 -0700 (PDT) In-Reply-To: References: Date: Thu, 9 Apr 2015 19:05:59 -0700 Message-ID: Subject: Re: `[[ -n $VAR ]]` equal to `[[ $VAR ]]`? From: Kurtis Rader To: Thorsten Kampe Cc: Zsh Users Content-Type: multipart/alternative; boundary=089e0158ab9098c6470513553421 --089e0158ab9098c6470513553421 Content-Type: text/plain; charset=UTF-8 Bart's reply explains why I get a parse error: Mac OS X still has zsh v5.0.5 which does not support the bash semantics for a bare string inside [[ ]]. Even if you don't need compatibility with pre v5.0.6 zsh releases I would discourage that syntax because of its ambiguity. On Thu, Apr 9, 2015 at 7:02 PM, Kurtis Rader wrote: > Okay, I had forgotten that a bare string is equivalent to "-n string" in > bash. The zsh documentation makes no mention of this "feature". It probably > works for you and not me because of an option that differs between our two > environments. Although for the life of me I can't figure out what that > option is. > > On Thu, Apr 9, 2015 at 6:39 PM, Thorsten Kampe > wrote: > >> * Kurtis Rader (Thu, 9 Apr 2015 18:31:04 -0700) >> > When I run the following >> > >> > [[ $VAR ]] && print yes >> > >> > I get a parse error. Which is what I expected given the documentation in >> > section "Conditional Expressions" of "man zshall". Are you seeing >> different >> > behavior? What makes you think a bare variable is a valid expression? >> >> >> ``` >> VAR= >> >> if [[ $VAR ]] >> then >> printf "something\n" >> else >> printf "nothing\n" >> fi >> ``` >> >> Works fine in zsh and bash. >> >> Same goes for >> `[[ $VAR ]] && printf "something\n" || printf "nothing\n"` >> >> > > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --089e0158ab9098c6470513553421--