bug-bash
[Top][All Lists]
Advanced

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

Re: fc -l history specification out of range with empty history


From: Chet Ramey
Subject: Re: fc -l history specification out of range with empty history
Date: Tue, 21 Mar 2017 11:59:56 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/21/17 11:35 AM, Grisha Levit wrote:
> If the history is empty (or if HISTSIZE is 1) running `fc -l' produces an 
> error:
> 
>     $ history -c
>     $ fc -l
>     bash: fc: history specification out of range

fc deals with the commands in the history list before the `fc' (that's
what the `previous command' in the Posix description means; it's equivalent
to -1).  So saying fc -l, which is equivalent to fc -l -16 (or
fc -l -16 -1), is out of range.  Even fc -l -1 is out of range.

ksh93 and mksh both print (different) errors; dash doesn't.

> I'm not sure this is necessary, since other instances of `first' and
> `last' being outside of the saved history range don't produce an
> error.  

Posix says explicitly that they don't when there are commands in the
history list, but you have to specify them.

Also the `history' command doesn't have this behavior:
> 
>     $ history -c
>     $ history
>         1  history

Because `history' doesn't skip to the previous command.

> As a special case, `fc -l -0' usually prints itself but not in the
> empty history (or HISTSIZE=1) case.

Yeah, that's a special case, but not when there are no commands in
the history list.

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://cnswww.cns.cwru.edu/~chet/



reply via email to

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