From: Eric Blake <eblake@redhat.com>
To: Herbert Xu <herbert@gondor.hengli.com.au>
Cc: "Taylan Ulrich B." <taylanbayirli@gmail.com>,
dash <dash@vger.kernel.org>
Subject: Re: 'continue' does not work in files sourced with dotcmd
Date: Thu, 07 Jul 2011 07:26:50 -0600 [thread overview]
Message-ID: <4E15B41A.9020601@redhat.com> (raw)
In-Reply-To: <20110707033749.GB16157@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]
On 07/06/2011 09:37 PM, Herbert Xu wrote:
> On Sat, Feb 26, 2011 at 06:23:54PM +0000, Taylan Ulrich B. wrote:
>> Using latest dash from git.
>> Transcript:
>>
>> $ echo continue > foo
>> $ for i in 1; do . ./foo; echo foobar; done
>> foobar
>> $
>
> While this does look inconsistent, this behaviour is not confined
> to dash. pdksh also does the same thing.
I've asked on the Austin Group whether this is a hole in POSIX, since
the standard appears to be silent on whether a for loop around a dot
script is visible to commands within the dot script.
>
> So I'm not particularly keen on changing this.
Unfortunately, I argue that dash DOES have a bug. Compare the zsh behavior:
$ zsh -c 'emulate sh; printf "continue\\necho \$?" > f; for i in 1; do .
./f; echo "$? hi"; done; rm f'
./f:continue:1: not in while, until, select, or repeat loop
1 hi
zsh rejected the continue statement (no containing loop within the
current scoping of the dot script), and as a result also aborted the
overall dot script - but in doing so, it properly emitted an error message.
Unless the Austin Group rules otherwise, I'm okay with dash rejecting
the continue command and aborting the dot script - but only on the
condition that the error is diagnosed, rather than silently papered
over. But it may be worth waiting for the Austin Group ruling, to see
if the bash/ksh behavior of continuing on to the loop that is enclosing
the dot script is required, or merely one possible alternative, before
changing dash behavior (that is, no point wiring up an error message
unless we know that issuing an error message complies with the standard).
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2011-07-07 13:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-26 18:23 'continue' does not work in files sourced with dotcmd Taylan Ulrich B.
2011-07-07 3:37 ` Herbert Xu
2011-07-07 13:26 ` Eric Blake [this message]
2011-07-07 14:46 ` Herbert Xu
2011-07-07 15:18 ` Eric Blake
2011-07-08 8:09 ` Herbert Xu
2011-07-09 13:07 ` Jilles Tjoelker
2011-07-09 14:07 ` Herbert Xu
2011-07-10 19:03 ` Jilles Tjoelker
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=4E15B41A.9020601@redhat.com \
--to=eblake@redhat.com \
--cc=dash@vger.kernel.org \
--cc=herbert@gondor.hengli.com.au \
--cc=taylanbayirli@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox