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