zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>, Zsh Users <zsh-users@zsh.org>
Subject: Re: curiosity with here document.
Date: Thu, 26 Nov 2015 22:01:16 +0300	[thread overview]
Message-ID: <434971448564476@web30o.yandex.ru> (raw)
In-Reply-To: <56575158.1070303@eastlink.ca>

26.11.2015, 21:38, "Ray Andrews" <rayandrews@eastlink.ca>:
> 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.


  reply	other threads:[~2015-11-26 19:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 18:37 Ray Andrews
2015-11-26 19:01 ` ZyX [this message]
2015-11-26 19:03 ` ZyX
2015-11-26 23:19   ` Ray Andrews
2015-11-27  1:56     ` Bart Schaefer
2015-11-27  2:29       ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434971448564476@web30o.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).