Re: [PATCH] Improved LINENO support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 12, 2010 at 08:07:41PM +0059, Harald van Dijk wrote:
> 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.

Hmm, I hadn't thought of that. I considered a LINENO that points to the
affected word most useful and easiest to implement (also because FreeBSD
sh's LINENO works this way).

So some more ideas:

A per-command LINENO does not require adding the number to all of the
node types. Only node types that are commands that perform expansions
need it: NCMD, NREDIR, NBACKGND, NSUBSHELL, NFOR, NCASE.

NFOR and NCASE may be wrapped in an NREDIR node to hold the line number.
This simplifies the code a bit at the cost of some extra memory usage.

A further simplification might be removing the redirect field from
NBACKGND and NSUBSHELL and putting any redirect in an additional NREDIR
node inside the NBACKGND/NSUBSHELL (so that the file is opened in the
child process and job control works correctly). However, NREDIR,
NBACKGND and NSUBSHELL are compatible types so it does not seem to gain
much.

What about making the lineno an element of the redirection list like
NTO? This minimizes changes to eval.c but perhaps it is too contrived.

Second idea: use a per-word LINENO but somehow ensure it is the same for
all words in a command. I think this is wrong, but perhaps I'm wrong.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux