bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#55838: 29.0.50; [PATCH] Eshell string-split subscript indexing split


From: Jim Porter
Subject: bug#55838: 29.0.50; [PATCH] Eshell string-split subscript indexing splits too much
Date: Tue, 7 Jun 2022 18:41:30 -0700

On 6/7/2022 6:36 PM, Jim Porter wrote:
 From "emacs -Q -f eshell":

   M-: (setq foo "a\nb:c")

   ~ $ echo $foo
   a
   b:c
   ~ $ echo $foo[: 0]
   ("a" "b")

The first command is normal, and just shows that Eshell outputs the string with no manipulation. In the second command, we split the string on ":" and get the 0th element. However, that gets split *again* (on newlines) and returns a list.

Here's a patch for this. It changes the behavior of `eshell-apply-indices' to use `eshell-convert-to-number' (when the expansion isn't wrapped in double-quotes) instead of the more-aggressive `eshell-convert'. I think `eshell-convert-to-number' is the right thing here, since Eshell already converts number-like strings to actual numbers in most cases.

As a note, if you wanted the old behavior, you could do something like this:

  ~ $ echo $foo[: 0][0 1]
  ("a" "b")

There's also a suggestion in the "Bugs and ideas" section of the Eshell manual to add "*" as a subscript to mean "all indices", so you could do the above in a more generic fashion like:

  ~ $ echo $foo[: 0][*]
  ;; Doesn't currently work, but it could.

Attachment: 0001-Don-t-split-Eshell-expansions-by-line-when-using-spl.patch
Description: Text document


reply via email to

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