GNU bug report logs -
#55838
29.0.50; Eshell string-split subscript indexing splits too much
Previous Next
Reported by: Jim Porter <jporterbugs <at> gmail.com>
Date: Wed, 8 Jun 2022 01:37:01 UTC
Severity: normal
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 55838 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
[0001-Don-t-split-Eshell-expansions-by-line-when-using-spl.patch (text/plain, attachment)]
This bug report was last modified 2 years and 347 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.