From: Harald van Dijk <harald@gigawatt.nl>
To: dash@vger.kernel.org
Cc: Eric Blake <eblake@redhat.com>, Jilles Tjoelker <jilles@stack.nl>
Subject: Re: [PATCH] Improved LINENO support
Date: Fri, 12 Nov 2010 20:07:41 +0059 [thread overview]
Message-ID: <4CDD9095.5070106@gigawatt.nl> (raw)
In-Reply-To: <4CDD8908.9010206@redhat.com>
On 12/11/10 19:35, Eric Blake wrote:
> On 11/12/2010 11:17 AM, Harald van Dijk wrote:
>> (
>> :
>> :
>> :
>> :
>> :
>> )>test-$LINENO
>>
>> should write to file test-1, not test-7, even though the only word is on
>> line 7. bash gets this wrong, pdksh gets this almost right.
>
> Umm - there was more than one word in that example (each : in the
> subshell is a word). But I agree that the subshell command itself
> started on line 1, but the word containing $LINENO is on line 7.
That was because it was a poor example. I meant to use comments, but
forgot to change this before posting. I haven't checked if they count as
words in SUS, but they don't in the dash source code.
> There are _so many_ variations on what this example would do that it's
> hard to say that any one version is definitively correct. In general,
> the standard tends to favor the ksh93 interpretation of things; but on
> your example, it touches the file test-6 (not test-7 nor test-1).
>
> All I can see in the standard is:
>
> "Set by the shell to a decimal number representing the current
> sequential line number (numbered starting with 1) within a script or
> function before it executes each command."
>
> with no hint as to whether LINENO auto-increments over the number of
> newlines encountered while parsing that command.
You may be right. SUS doesn't really specify whether "current" refers to
the first or the last line number of a command. test-1 and test-7 are
equally defensible, so I was too quick to say that bash gets this wrong.
I hope you agree, though, that test-6 is iffy, and for my other example:
echo $LINENO \
$LINENO
two identical numbers must be printed. SUS only requires and only allows
LINENO to be set before a command is executed, so once it is set, it is
set for both expansions. Given that,
(
#
#
#
#
#
)>test-$LINENO \
>>test2-$LINENO
must not write to test-7 and test2-8. It may write to test-1 and
test2-1, or it may write to test-8 and test2-8. Perhaps even to test-7
and test2-7. Again, though, LINENO must be the same in both expansions.
So for dash, the problem doesn't change: storing the line number of each
word, rather than each command, makes it very hard to get LINENO right.
next prev parent reply other threads:[~2010-11-12 19:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-08 20:33 [PATCH] Improved LINENO support Harald van Dijk
2010-11-10 22:00 ` Jilles Tjoelker
2010-11-11 20:33 ` Harald van Dijk
2010-11-12 18:17 ` Harald van Dijk
2010-11-12 18:35 ` Eric Blake
2010-11-12 19:08 ` Harald van Dijk [this message]
2010-11-12 19:40 ` Harald van Dijk
2010-11-12 21:29 ` Jilles Tjoelker
2010-11-27 16:56 ` Harald van Dijk
2011-03-10 8:10 ` Herbert Xu
2011-03-11 21:56 ` Harald van Dijk
2011-03-15 7:52 ` Herbert Xu
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=4CDD9095.5070106@gigawatt.nl \
--to=harald@gigawatt.nl \
--cc=dash@vger.kernel.org \
--cc=eblake@redhat.com \
--cc=jilles@stack.nl \
/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