Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: curiosity with here document.
- X-seq: zsh-users 21002
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: curiosity with here document.
- Date: Thu, 26 Nov 2015 17:56:25 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=5BVmBgI8nX6goFQ8RwM2HfFDKt8HHPyx+StKPnmppZI=; b=tpyYthIcgLkd+N0qy1dT+lZsg5/UbxmRDQ/4Vc9TNq8kTRsObnU0yVV3CiKoFD/Mle 5i0ogF9omS4TdyI9LldUtzUMigoncMy5H09fd1kSzUGJccwnbFzwV/YHeRYNaY+TNeKN zFt7uGGtGf8xqyx0EQzn+Y/nEo9EbDXCags7IbozUMFFiI0UaA5Fd0DYTM+gWOiJVZR7 83Uf3WDtkS2TAqkFZka055xEzRxIG3+MKqhz4pfIXSHMMhgukWgX/y2/C+6rEyiuZORl 0EUgcDOTeH1P4+Yqix6PUyIFYG6oFJUJa6O0Lzn4auZHYPwneGjmImKfXhTBDBjEQzNB nxvw==
- In-reply-to: <5657939E.7070106@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> <1330101448564591@web8j.yandex.ru> <5657939E.7070106@eastlink.ca>
On Nov 26, 3:19pm, Ray Andrews wrote:
}
} lesson learned.
Except it's the wrong lesson! What you *ought* to learn is, first, that
for purposes of determining the "truth value" (zero or nonzero return
status),
if command1; command2; command3; then ...
is the same as
function three_commands {
command1; command2; command3
}
if three_commands; then ...
And second, that [[ ... ]] is just a command like any other command,
it's not magically connected to "if". Further, ":" is also a command
like any other command.
And third, that a here-document is just the standard input of the
command it follows, so
: <<END
some stuff
END
is (again for purposes of determining truth value) the same as
:
and the colon command is "true" for purposes of if/while/until/etc.,
it has a return status of zero. So what you've written is
if [[ ... ]]; : ; then ...
and colon is true and is the last command before the "then", so the
true branch is taken.
The here-document itself has no true or false interpretation, and the
presence of the here-document is not what is causing "if" to behave
the way it does.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author