Subject: Re: bug#26055: 25.1; Eshell dollar expansion $var[i] not working

From: [email-masked]
Date: Fri, 09 Jun 2017 20:33:26 -0400

tags 26055 patch
quit

[email-masked] writes:

> Since this apparently never worked it's hard to say what's supposed to
> happen, but it looks like a 'number' property is added and then ignored.
> Maybe something like this should be applied?

Since `eshell-lisp-command' does the conversion of strings marked with
'number', I think it's correct to make eshell-index-value do so as well.

>From bacbb41ab4d5539d284b1a540e70779a49c00e25 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Fri, 9 Jun 2017 19:40:38 -0400
Subject: [PATCH v1] Handle integer indices for eshell variables (Bug#26055)

* lisp/eshell/esh-var.el (eshell-index-value): Convert index to number
if it's been marked as one, just like `eshell-lisp-command' does.
---
 lisp/eshell/esh-var.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index fe1f1188c8..cdd05bd7e9 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -563,6 +563,8 @@ (defun eshell-apply-indices (value indices)
 
 (defun eshell-index-value (value index)
   "Reference VALUE using the given INDEX."
+  (when (and (stringp index) (get-text-property 0 'number index))
+    (setq index (string-to-number index)))
   (if (stringp index)
       (cdr (assoc index value))
     (cond
-- 
2.11.1