bug-coreutils
[Top][All Lists]
Advanced

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

Re: [RFC] linecut addition


From: Matthew Woehlke
Subject: Re: [RFC] linecut addition
Date: Tue, 09 Oct 2007 15:44:23 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.0

Steven Schubiger wrote:
Matthew Woehlke wrote:
Well, yes, I would hope so. If you can't write 'a + b' in your program, something is wrong ;-). (Use case is of course e.g. scripts where the beginning line is not known in advance, but you know you want N lines total.)

Am I right assuming you mean something like '-20,+3' ?

I was thinking more '${startline},+3', but yes, '-20,+3' should also work (equivalent to '-20,-18'... er, see below).

Ok. (An alternative, if sed-like format wins, would of course be '5,$', but '5,-0' is fine.)

I'm a bit hesitant to make it look too much like sed.
And I must correct myself here: "1,-1" is valid, whereas "1,-0" isn't.

'-1' means "the last line" and not "the last line minus one"? I'm not sure if that's right, but then, I'm not sure it's wrong either so take this sentence with a large grain of salt.

I was asking you :-). Personally I think printing lines backwards is probably not so good an idea, so I would either match only the first line, or else print a warning to stderr.

I think we should disallow it entirely. Worry later about the details.

Disallowing it is fine, but if you disallow it, it seems reasonable to expect the program to say that it was disallowed :-). (I'm on the fence if this counts as a specification or implementation detail.)

Anyway '5,2' was just an "obvious" example; I would expect this to be more likely with a range like '5,-5' on input with fewer than nine lines.

Agreed (except s/nine/ten/).

Erm... no, I think nine is right...

line  n  -n
1     1  -9
2     2  -8
3     3  -7
4     4  -6
5     5  -5
6     6  -4
7     7  -3
8     8  -2
9     9  -1

...so '5,-5' in this case refers to one line... the fifth one.

(ok, so that implies that 'last line == -1' is right... sheesh, I'm not even consistent within one e-mail. Although it seems you have the same problem ;-).)

So I guess it's important to specify if '-1' means "the last line", or "the n'th-to-last last line (n==1 in this example)" (in which case '-0' means something). Similarly, if 'n,+k' means "k line(s), starting at n" or "line n plus k line(s)". Possibly best to pick so that '-0' and '+0' both either make sense or do not make sense. I think I lean towards being all one-based.

--
Matthew
morphir: so much confusion :S kmake, kdemake, qmake make cmake etc.
logixoul: you forgot cmakekde :)
morphir: and bakemeacake





reply via email to

[Prev in Thread] Current Thread [Next in Thread]