Subject: 24.4; Eshell history substitution causes error

From: Emanuel Evans <[email-masked]>
Date: Wed, 05 Nov 2014 11:45:07 -0800

I'm not entirely sure whether history substitution in Eshell is a
supported feature, but attempting to use it leads to an error. Steps to
reproduce (from emacs -Q, with debug-on-error set to t):

1. M-x eshell
2. cd /
3. ls bin
4. ^bin^usr

Expected result: output of "ls usr"
Actual result: stacktrace:

Debugger entered--Lisp error: (wrong-type-argument stringp 108)
  string-match("bin" 108)
  (if (string-match "bin" str) (setq str (replace-match "usr" t nil str)))
  (lambda (str) (if (string-match "bin" str) (setq str (replace-match "usr" t nil str))) str)(108)
  mapcar((lambda (str) (if (string-match "bin" str) (setq str (replace-match "usr" t nil str))) str) "lsbin")
  (lambda (lst) (mapcar (function (lambda (str) (if (string-match "bin" str) (setq str (replace-match "usr" t nil str))) str)) lst))("lsbin")
  eshell-hist-parse-modifier("lsbin" ":s/bin/usr/")
  eshell-history-reference("^bin^usr")
  eshell-expand-history-references(#<marker at 777 in *eshell*> 785)
  run-hook-with-args(eshell-expand-history-references #<marker at 777 in *eshell*> 785)
  #[0 "\300\304	`S\"\240\210\305\306	`S#\210\307	`S\"\211\205?.\310	!\210\300\304\nS\"\240\210\311\312!\210\313\314\315\316\317\320\321\300.\"\322\"\323\324%D\215\205?.\325 \207" [("^bin^usr") eshell-last-output-end eshell-last-input-start eshell-last-input-end buffer-substring-no-properties run-hook-with-args eshell-expand-input-functions eshell-parse-command-input eshell-update-markers run-hooks eshell-input-filter-functions eshell-terminal funcall make-byte-code 0 "\302\303\301!\203\f.\304\301!\210\207\305\301\300\242\"\210\207" vconcat vector [nil eshell-invoke-directly eval eshell-eval-command] 4 "\n\n(fn)" eshell-life-is-too-much] 10 "\n\n(fn)"]()
  funcall(#[0 "\300\304	`S\"\240\210\305\306	`S#\210\307	`S\"\211\205?.\310	!\210\300\304\nS\"\240\210\311\312!\210\313\314\315\316\317\320\321\300.\"\322\"\323\324%D\215\205?.\325 \207" [("^bin^usr") eshell-last-output-end eshell-last-input-start eshell-last-input-end buffer-substring-no-properties run-hook-with-args eshell-expand-input-functions eshell-parse-command-input eshell-update-markers run-hooks eshell-input-filter-functions eshell-terminal funcall make-byte-code 0 "\302\303\301!\203\f.\304\301!\210\207\305\301\300\242\"\210\207" vconcat vector [nil eshell-invoke-directly eval eshell-eval-command] 4 "\n\n(fn)" eshell-life-is-too-much] 10 "\n\n(fn)"])
  eshell-send-input(nil)
  call-interactively(eshell-send-input nil nil)
  command-execute(eshell-send-input)

In GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
 of 2014-10-29 on WorkBook-Pro-II.local
Configured using:
 `configure --prefix=/usr/local/Cellar/emacs/24.4
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/24.4/share/info/emacs --without-dbus
 --with-gnutls --with-rsvg --with-imagemagick --with-ns
 --disable-ns-self-contained'

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: EShell

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ ? 1 ; 2 c ESC x e s h TAB RET c d SPC / RET l 
s SPC b i n RET ^ b i n ^ u s r RET DEL DEL DEL DEL 
DEL DEL DEL DEL ESC x s e t - v a TAB RET d e u DEL 
b u g TAB o n TAB e r TAB RET t RET ESC O A ESC O A 
ESC O B RET ESC O A ESC O A ESC O A ESC O A ESC O A 
ESC O A ESC O B ESC O B ESC O B ESC O B ESC O B ESC 
O B DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL 
DEL ^ b i n ^ u s r RET C-a C-@ ESC > ESC w q ESC x 
r e p o r t TAB RET

Recent messages:
History item: 11
History item: 12
History item: 13
History item: 14
History item: 1
delete-backward-char: Text is read-only
Entering debugger...
Mark set
Saved text from "Debugger entered--Lisp error: (wrong-typ"
Back to top level.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug help-mode debug cus-edit wid-edit
cus-start cus-load em-unix em-term term disp-table ehelp em-script
em-prompt em-ls em-hist em-pred em-glob em-dirs em-cmpl em-basic
em-banner em-alias pcomplete comint ansi-color ring esh-var esh-io
esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell
esh-module esh-mode esh-util gnutls cl-loaddefs cl-lib mm-archive
message format-spec rfc822 mml easymenu mml-sec mailabbrev gmm-utils
mailheader mm-decode mm-bodies mm-encode network-stream starttls
url-http tls mail-parse rfc2231 url-gw url-cache url-auth url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse url-vars epg smtpmail
auth-source eieio byte-opt bytecomp byte-compile cconv eieio-core
gnus-util password-cache sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils package epg-config xterm time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
ns-win tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
cocoa ns multi-tty emacs)

Memory information:
((conses 16 151620 23576)
 (symbols 48 25175 0)
 (miscs 40 49 239)
 (strings 32 33041 6577)
 (string-bytes 1 919530)
 (vectors 16 22524)
 (vector-slots 8 1192094 156060)
 (floats 8 83 614)
 (intervals 56 511 95)
 (buffers 960 15))