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


Groups > gnu.bash.bug > #16741

[PATCH] fc: trim range instead of erroring out

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject [PATCH] fc: trim range instead of erroring out
Date Tue, 11 Aug 2020 16:59:57 +0100
Lines 74
Approved bug-bash@gnu.org
Message-ID <mailman.1580.1597161606.2739.bug-bash@gnu.org> (permalink)
References <bee8013d-39e9-7433-934f-89fce4134369@inlv.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/mixed; boundary="------------3DCC80151DA6249570A46CA7"
X-Trace usenet.stanford.edu 1597161607 14743 209.51.188.17 (11 Aug 2020 16:00:07 GMT)
X-Complaints-To action@cs.stanford.edu
To Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.11.0
Content-Language en-GB
Received-SPF none client-ip=2a02:2770::21a:4aff:fec6:e3d8; envelope-from=martijn@inlv.org; helo=freekahlil.inlv.org
X-detected-operating-system by eggs.gnu.org: No matching host in p0f cache. That's all we know.
X-Spam_score_int -8
X-Spam_score -0.9
X-Spam_bar /
X-Spam_report (-0.9 / 5.0 requ) BAYES_00=-1.9, MAY_BE_FORGED=1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <bee8013d-39e9-7433-934f-89fce4134369@inlv.org>
Xref csiph.com gnu.bash.bug:16741

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

As I use/try/test many shells, I'm in the habit of using POSIX commands 
such as 'fc -l 1' to list the complete history.

If there have been more than $HISTSIZE command, the list is trimmed at 
the beginning without renumbering, and bash errors out:

$ fc -l 1
bash-5.0: fc: history specification out of range

This is different from every other shell, and also looks like it's 
contrary to the POSIX spec:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/fc.html#tag_20_44_05
| When a range of commands is used, it shall not be an error to specify
| first or last values that are not in the history list; fc shall
| substitute the value representing the oldest or newest command in the
| list, as appropriate. For example, if there are only ten commands in
| the history list, numbered 1 to 10:
|
| fc -l
| fc 1 99
|
| shall list and edit, respectively, all ten commands.

The attached patch removes the error and limits the range to available 
commands as specified.

- Martijn

-- 
||	modernish -- harness the shell
||	https://github.com/modernish/modernish
||
||	KornShell lives!
||	https://github.com/ksh93/ksh

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


Thread

[PATCH] fc: trim range instead of erroring out Martijn Dekker <martijn@inlv.org> - 2020-08-11 16:59 +0100

csiph-web