Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: curiosity with here document.
- X-seq: zsh-users 20997
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: curiosity with here document.
- Date: Thu, 26 Nov 2015 22:01:16 +0300
- 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=
- In-reply-to: <56575158.1070303@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <56575158.1070303@eastlink.ca>
26.11.2015, 21:38, "Ray Andrews" <rayandrews@xxxxxxxxxxx>:
> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author