• Shell command history (was: Useless Use Of Regexes)

    From Geoff Clare@21:1/5 to All on Wed Apr 9 13:26:48 2025
    c186282 wrote:

    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:
    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with some
    old version of VxWorks. It was the only kind included by default. I
    ended up teaching some colleagues on how to edit the command line, vi
    style.

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    That's not how it works. After the shell writes a command prompt,
    it is in insert mode, so you just type a command as normal. To edit
    the current command, or search the history, you type ESC to get out
    of insert mode and then perform the edit or search just like in vi
    (except that RETURN executes the edited command instead of moving to
    the next "line").

    It's terrible - and was obsolete already by 1985.

    It became an IEEE standard in 1992 (and ISO in 1993) for
    POSIX-conforming shells, and has remained standard to this day.
    IEEE chose not to include emacs mode, so effectively it is emacs
    mode that was treated as obsolete (in 1992).

    --
    Geoff Clare <[email protected]>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Geoff Clare on Sat Apr 12 06:55:05 2025
    On Wed, 9 Apr 2025 13:26:48 +0100, Geoff Clare wrote:

    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:

    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with
    some old version of VxWorks. It was the only kind included by
    default. I ended up teaching some colleagues on how to edit the
    command line, vi style.

    Seems a bit dumb, having to go into insert mode every time you
    actually want to type a command.

    That's not how it works.

    But that’s how the vi/vim editor family works. Are you saying that a command-line editor that is supposed to work like those editors doesn’t in fact, emulate them entirely faithfully?

    After the shell writes a command prompt, it is
    in insert mode, so you just type a command as normal. To edit the
    current command, or search the history, you type ESC to get out of
    insert mode and then perform the edit or search just like in vi (except
    that RETURN executes the edited command instead of moving to the next "line").

    Seems like a lot of unnecessary back-and-forth.

    It became an IEEE standard in 1992 (and ISO in 1993) for
    POSIX-conforming shells, and has remained standard to this day. IEEE
    chose not to include emacs mode, so effectively it is emacs mode that
    was treated as obsolete (in 1992).

    Nevertheless, that is the one that is most commonly used in *nix systems
    today.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to [email protected] on Sat Apr 12 23:55:52 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <[email protected]d> wrote:
    On Wed, 9 Apr 2025 13:26:48 +0100, Geoff Clare wrote:
    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:
    Seems a bit dumb, having to go into insert mode every time you
    actually want to type a command.
    That's not how it works.

    But that’s how the vi/vim editor family works. Are you saying that a command-line editor that is supposed to work like those editors doesn’t in fact, emulate them entirely faithfully?

    It is not advertised as an "entirely faithfully" emulation. In fact, the
    crappy vi-mode in early versions of bash is why I ended up preferring
    ksh, which I still use to this day when available.

    It is advertised as "vi-style command line editing interface" in recent
    bash and readline man-pages, and "a vi style in-line editor" in ksh's
    manpage. One of the key differences, which is very helpful for shell
    usage, is every line starts in insert mode.

    Other things missing from "vi-style" (or "vi style") are the : commands
    and most multiline movement commands, eg H, L, M (, ), {, }, [[, ]], and
    gg. But G does work to go to oldest item in history.

    Elijah
    ------
    overall it works better than the vi included with busybox

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Lawrence D'Oliveiro on Mon Apr 14 09:47:22 2025
    On 2025-04-12, Lawrence D'Oliveiro wrote:

    On Wed, 9 Apr 2025 13:26:48 +0100, Geoff Clare wrote:

    It became an IEEE standard in 1992 (and ISO in 1993) for
    POSIX-conforming shells, and has remained standard to this day. IEEE
    chose not to include emacs mode, so effectively it is emacs mode that
    was treated as obsolete (in 1992).

    Nevertheless, that is the one that is most commonly used in *nix systems today.

    Oh, I didn't know Emacs edit mode was that common, which other shells
    support it besides GNU bash?

    (Yes, we're in comp.os.linux.misc, but, following the mention of "*nix systems", I'm talking about shells in all such systems, not just
    linux-based systems.)

    --
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Nuno Silva on Mon Apr 14 22:37:06 2025
    On Mon, 14 Apr 2025 09:47:22 +0100, Nuno Silva wrote:

    Oh, I didn't know Emacs edit mode was that common, which other shells
    support it besides GNU bash?

    It’s not the shell specifically that supports it, remember. It’s actually
    a separate library called GNU readline, that is also used by a lot of
    other software.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to [email protected] on Tue Apr 15 23:28:35 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <[email protected]d> wrote:
    On Mon, 14 Apr 2025 09:47:22 +0100, Nuno Silva wrote:
    Oh, I didn't know Emacs edit mode was that common, which other shells
    support it besides GNU bash?
    It’s not the shell specifically that supports it, remember. It’s actually

    Well akshuly. In ksh it is built into the shell, not gnu. That's how I
    used it with the shells on HP-UX and Solaris.

    It’s not the shell specifically that supports it, remember. It’s actually a separate library called GNU readline, that is also used by a lot of
    other software.

    Gnu readline is used in bc(1), for example, which lets me have have vi
    mode there, but it has also caused the bc developers to lose the ability
    to have blank lines from a user hitting enter twice.

    I complained to [email protected] in 2022 about this and got back a reply
    from Phil Nelson:

    | This appears to be a GNU Readline issue. Readline never sends the
    | blank line to bc. I've tried to track it down, but with no success.

    Elijah
    ------
    can't think of any other programs where he encounters readline()

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Eder@21:1/5 to Eli the Bearded on Wed Apr 16 10:09:02 2025
    On Di 15 Apr 2025 at 23:28, Eli the Bearded <*@eli.users.panix.com> wrote:

    Well akshuly. In ksh it is built into the shell, not gnu. That's how I
    used it with the shells on HP-UX and Solaris.

    In zsh it is the same - no readline there.

    'Andreas
    --
    ceterum censeo redmondinem esse delendam

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Eli the Bearded on Wed Apr 16 21:33:01 2025
    On Tue, 15 Apr 2025 23:28:35 -0000 (UTC), Eli the Bearded wrote:

    can't think of any other programs where he encounters readline()

    <https://docs.python.org/3/library/readline.html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to [email protected] on Fri Apr 18 04:22:27 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <[email protected]d> wrote:
    On Tue, 15 Apr 2025 23:28:35 -0000 (UTC), Eli the Bearded wrote:
    can't think of any other programs where he encounters readline()
    <https://docs.python.org/3/library/readline.html>

    That's just a wrapper to use in in Python scripts that interact with
    the user. I do not believe I have ever encountered a script using it.
    But that does remind me that the Perl CPAN shell can optionally use
    the Perl wrapper of the readline library. I don't usually have that
    Perl wrapper installed however.

    Elijah
    ------
    knows it is used in programs outside his concern

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Lawrence D'Oliveiro on Fri Apr 18 10:31:13 2025
    On 2025-04-14, Lawrence D'Oliveiro wrote:

    On Mon, 14 Apr 2025 09:47:22 +0100, Nuno Silva wrote:

    Oh, I didn't know Emacs edit mode was that common, which other shells
    support it besides GNU bash?

    It’s not the shell specifically that supports it, remember. It’s actually a separate library called GNU readline, that is also used by a lot of
    other software.

    What is "*the* shell"?

    The question is the same, whether this is implemented internally or in a separate library (GNU or non-GNU). Are Emacs keybindings that usual in
    UNIX shells?

    --
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Eli the Bearded on Sat Apr 19 22:34:49 2025
    On Fri, 18 Apr 2025 04:22:27 -0000 (UTC), Eli the Bearded wrote:

    In comp.os.linux.misc, Lawrence D'Oliveiro <[email protected]d> wrote:

    On Tue, 15 Apr 2025 23:28:35 -0000 (UTC), Eli the Bearded wrote:

    can't think of any other programs where he encounters readline()

    <https://docs.python.org/3/library/readline.html>

    That's just a wrapper to use in in Python scripts that interact with
    the user.

    ldo@theon:~> apt-cache rdepends libreadline8t64 | wc -l
    325

    Do you want a full list?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to [email protected] on Sun Apr 20 18:26:35 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <[email protected]d> wrote:
    On Fri, 18 Apr 2025 04:22:27 -0000 (UTC), Eli the Bearded wrote:
    That's just a wrapper to use in in Python scripts that interact with
    the user.

    ldo@theon:~> apt-cache rdepends libreadline8t64 | wc -l
    325

    Do you want a full list?

    The things using libreadline and the things using the Python libreadline
    are different. sqlite3, for example, is in the list, but isn't using
    Python. I've already pointed out there's a Perl libreadline library,
    too.

    (I perused the full list on my system and very few were things that I
    have run in say, the last 12 months, but sqlite3 and gdb are there and
    I've used those.)

    Elijah
    ------
    not quite sure why inkscape is on the list

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)