delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/04/03/17:18:16

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=boiswL
YLzhB3ZndUOFUQ0DcNUaQcfGFLRt1mtxny7Tjc4kGsX/VorWrO2iBq0ONDMrPJ+P
4yy8RZmzOc/2dJgha02YJ7QCi1Ub6s0lgz2/3WI7E3ZcUG6VOWGZmM4FrYYQFHLH
DshbIMbog5qjKF3/+gi3Yfh0HhyN7dtfBP1vs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=I2zVmhK/eQus
Y30TRXcMnvVuw+E=; b=Drq768uNZr1xOixaJl+HZvz23D2Bcssd9FXpNyak5VzY
xzLdsOTgasP9BjKvr3kbaJMamk8ymtmSJbP36MqQOEEGTttD6Jc9Ldj7/SSKemoZ
vUaT0K6O5aD7rm0yNB5Qg6Q/GIClLNN5YDhV5+iFapGwnaJFRSauXByPmhKAHuE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1
Message-ID: <515C9C7C.3060405@redhat.com>
Date: Wed, 03 Apr 2013 15:17:48 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Here-Document execution fails with extra space after closing delimiter
References: <21821681 DOT 1365022967088 DOT JavaMail DOT root AT wamui-junio DOT atl DOT sa DOT earthlink DOT net>
In-Reply-To: <21821681.1365022967088.JavaMail.root@wamui-junio.atl.sa.earthlink.net>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-Virus-Found: No

------enig2WSKRCWXPTPNQPOUIOKBQ
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 04/03/2013 03:02 PM, shawn kielty wrote:
> this script works:=20
> #! /bin/bash
>=20
> tclsh << SCRIPT=20
> puts "hello world"=20
> SCRIPT

Correct.

>=20
> while this script fails:=20
>=20
> #! /bin/bash
>=20
> tclsh << SCRIPT=20
> puts "hello world"=20
> SCRIPT=20

Here-docs are particular.  The end token must appear verbatim, exactly
as the start token was parsed - but the parser strips off trailing
space, so it is looking for a line matching exactly 'SCRIPT', and your
'SCRIPT ' is not such a line.  The error message is correct.  This is
not a cygwin-specific problem.

>=20
> with the error:
>=20
>=20
> $ ./embeddedTcl.sh
> ./embeddedTcl.sh: line 5: warning: here-document at line 3 delimited by e=
nd-of-file (wanted `DEL')
> hello world
> invalid command name "DEL"

The bit about 'wanted `DEL'' and 'invalid command name "DEL"' tells me
that you aren't faithfully copying-and-pasting when typing up your
email.  When I try on Linux, I get:

$ bash -c 'cat << foo
> hi
> foo '
bash: line 2: warning: here-document at line 0 delimited by end-of-file
(wanted `foo')
hi
foo

where the message from bash mentions the spelling it is looking for, not
some arbitrary string `DEL'.

Other shells (I tried dash, mksh, ksh, and zsh) are a bit more
forgiving, but ALL of them treat a line that does not match the expected
terminator (because it has an erroneous trailing space) as part of the
here-doc contents - all bash is doing differently is warning you about
the issue before proceeding on anyways.

The _only_ thing that might make this cygwin-specific is if the
unintentional trailing whitespace in your script is due to you using
carriage returns in part, but not all, of your file, and even then, you
can tell bash to ignore carriage returns on cygwin (it's not on by
default for various reasons, but lots of people use that mode to
compensate for sloppy habits in editing files).

--=20
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


------enig2WSKRCWXPTPNQPOUIOKBQ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJRXJx8AAoJEKeha0olJ0Nql34H/2oyUufm9WLfLbGAQPfBWjkf
2kT5PWVBXrRfQqFvZ7PwXBnEVCuHDeEmtNC0++PywlKHeNxqsoGQd9kTQD8Npkop
EA23q8IRQyqGSK+yPjDbKTrVwipHnqxU4jyZ7VrVvgyW0Qd4q1t7agJn+R2roq9Z
zbaq0aFYogF+zoJEI2TxxDSm6+HjgSXxahasQdiDM1mE9NDqrtURgbJV8KtTSPC8
5DJjrv78TupIozs+DYSUvCRZZAJgdqOkZtDgG48GJh9YaBNOKVfSG1l8A0qXBZxI
yUl5eqc7puaHd86HghLkrGIsAin6qyLzEKMmaIMFk9aF5QreytWHbiFqGZrAT+M=
=zBhP
-----END PGP SIGNATURE-----

------enig2WSKRCWXPTPNQPOUIOKBQ--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019