Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16285

Re: [bug] Segmentation fault in the "fc" builtin

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: [bug] Segmentation fault in the "fc" builtin
Date 2020-05-05 16:10 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.2180.1588709430.3066.bug-bash@gnu.org> (permalink)
References <06953bf8-5526-bb86-b878-2dcf9864acec@quoininc.com> <6ec4bd02-4aa3-3e03-980d-9744669c7270@case.edu> <0774c9ef-a992-8353-6e07-3e9c6e56d923@quoininc.com> <ae11c5fa-3b29-4853-24e5-1eb4b28810b5@case.edu>

Show all headers | View raw


On 5/5/20 12:16 PM, Franklin, Jason wrote:

> Agreed.  This is an undocumented feature, which is why Brandon and I had
> a bit of trouble figuring out what "should" happen. :/
> 
>> I'm leaning towards making 0 and -0 out-of-range errors for the non-listing
>> case. This is what other shells do (the netbsd and freebsd shells being
>> notable exceptions).
> 
> Well, I think 0 and -0 have different intentions as it stands.

In bash, yes. Nowhere else. They both require special handling.

> Currently, "0" indicates the command right before the "fc" invocation
> that caused the editing or listing.  This shouldn't ever cause an
> infinite loop and should not be an out-of-range error, I assert.

Yes, it's equivalent to -1. That's just giving it semantics, not providing
any unique functionality. It could just as easily have been an error, as
POSIX intended.

> Example session:
> 
>   bash-5.0$ true # example command
>   bash-5.0$ fc -l 0
>   48       true # example command
>   bash-5.0$
> 
> Thus, the argument in question is specifically "-0" proper.  This, to
> me, means "the fc command itself" that did this work.
> 
> Would a good solution be to have "0" function as-is, but have "-0" only
> be valid in the listing case?  This would avoid the problem above.

This is about the only reasonable alternative.

> Of course, documenting the intent of the feature would be key to making
> the change a successful one!

I'll come up with something.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: [bug] Segmentation fault in the "fc" builtin Chet Ramey <chet.ramey@case.edu> - 2020-05-05 16:10 -0400

csiph-web