Module Name:    src
Committed By:   kre
Date:           Fri Jul  5 04:07:26 UTC 2024

Modified Files:
        src/bin/sh: histedit.c

Log Message:
Don't emit a user causable "internal error" message.

Non-numeric args to "fc" simply fail to find the string
in an empty history buffer, as they might in a non-empty
history, and generate a reasonable error message.

But normally, as numeric args to the "fc" utility are trimmed
to the bounds of the contents of the history buffer, it
is impossible for them to fail to find an entry, as at the
very least the "fc" command itself should be there.

Hence "sh" claimed such a thing was an "internal error".

But it is possible to run fc commands, not entered from
stdin, and so not eligible for the history buffer, before
any interactive commands are entered.   In such a case
the history buffer will be empty, which "sh" has been
reporting as an "internal error".   It isn't.
Generate a more meaningful (and less scary) message instead.

No pullups planned - the code has been like this for a
very long time, and no-one ever noticed, as it would be
very (VERY) unusual for the "fc" utility to be invoked
at a time when the history buffer is active & empty, given
the way the code currently exists (unlikely, not impossible).

This change is more in preparation for future possible
changes which would make this error easier to encounter.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/bin/sh/histedit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Reply via email to