From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20294 invoked by alias); 26 Nov 2015 19:07:36 -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: 20997 Received: (qmail 18027 invoked from network); 26 Nov 2015 19:07:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1448564477; bh=9vCVSGlGuXFMQ07n0QalLumxYsemdUNEHKlyVcqBs4U=; h=From:To:In-Reply-To:References:Subject:Date; b=ZHV04YtarDAnZ9xtGMq+QR65HO26WaoMBHAW5aKAg90FdB0qnAG/M1rwA/r6AIA+9 fkMNog+GaajwUJSZDXpi6obmLQ8XqruguW1b88HRLAKRJCU2admr+YroGo7whaXmeK 3JQYaILKhf1rU6Uxb8cHShhwtOJZSE960946wRzg= From: ZyX To: Ray Andrews , Zsh Users In-Reply-To: <56575158.1070303@eastlink.ca> References: <56575158.1070303@eastlink.ca> Subject: Re: curiosity with here document. MIME-Version: 1.0 Message-Id: <434971448564476@web30o.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Thu, 26 Nov 2015 22:01:16 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 26.11.2015, 21:38, "Ray Andrews" : > I often comment out blocks of code with here-document, and I just found > this strange thing: > > šššš/test1 ()/ > šššš/{/ > šššš/ if [[ "$1" = 'howdy' ]];/ > > šššš/: <<'COMMENT'/ > šššš/blah blah > ššššCOMMENT/ > > šššš/ then/ > šššš/ echo stranger/ > šššš/ fi/ > šššš/}/ > > šššš/$ test1 no/ > šššš/stranger/ > > There's no issue if I put the 'then' above the here-document. How should > I understand that? It is as if the here-document is hijacking the 'if' > test and returning true. I'd expect the 'if' to go hunting for it's > 'then' and if it doesn't find it, then throw and error, but not let the > here-document interlope. But if this is proper then it's a caution as > to using these things for commenting. This has nothing to do with here document. You can have any *sequence* of commands as the `if` condition, including `:`. What this sequence returns is used for the if: if true; false then echo True else echo False fi will echo False.