aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Kyle Mitchell2018-07-16 21:46:20 -0500
committerNoam Postavsky2018-07-21 21:07:07 -0400
commit5de444112cf19c078d4a74752a50e890233ef033 (patch)
treef11385229d305768fafbef137a60f6533981d15b
parent1b4b96597c7868d9c24389d83089097a521206a5 (diff)
downloademacs-5de444112cf19c078d4a74752a50e890233ef033.tar.gz
emacs-5de444112cf19c078d4a74752a50e890233ef033.zip
Check for special filenames in eshell (Bug#30724)
* lisp/eshell/esh-cmd.el (eshell-lisp-command): Check for "~" in lisp commands with the eshell-filename-arguments property (Bug#30724). * lisp/eshell/em-dirs.el (eshell/cd, eshell/pushd, eshell/popd): * lisp/eshell/em-ls.el (eshell/ls): * lisp/eshell/em-unix.el (eshell/rm, eshell/mkdir, eshell/rmdir) (eshell/mv, eshell/cp, eshell/ln, eshell/cat, eshell/du, eshell/diff): * lisp/eshell/esh-ext.el (eshell/addpath): Add eshell-filename-arguments to symbol plist.
-rw-r--r--lisp/eshell/em-dirs.el3
-rw-r--r--lisp/eshell/em-ls.el1
-rw-r--r--lisp/eshell/em-unix.el10
-rw-r--r--lisp/eshell/esh-cmd.el51
-rw-r--r--lisp/eshell/esh-ext.el1
5 files changed, 45 insertions, 21 deletions
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 37cb6b169a0..ba3bdb5cd53 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -407,6 +407,7 @@ in the minibuffer:
407 nil)))) 407 nil))))
408 408
409(put 'eshell/cd 'eshell-no-numeric-conversions t) 409(put 'eshell/cd 'eshell-no-numeric-conversions t)
410(put 'eshell/cd 'eshell-filename-arguments t)
410 411
411(defun eshell-add-to-dir-ring (path) 412(defun eshell-add-to-dir-ring (path)
412 "Add PATH to the last-dir-ring, if applicable." 413 "Add PATH to the last-dir-ring, if applicable."
@@ -470,6 +471,7 @@ in the minibuffer:
470 nil) 471 nil)
471 472
472(put 'eshell/pushd 'eshell-no-numeric-conversions t) 473(put 'eshell/pushd 'eshell-no-numeric-conversions t)
474(put 'eshell/pushd 'eshell-filename-arguments t)
473 475
474;;; popd [+n] 476;;; popd [+n]
475(defun eshell/popd (&rest args) 477(defun eshell/popd (&rest args)
@@ -500,6 +502,7 @@ in the minibuffer:
500 nil) 502 nil)
501 503
502(put 'eshell/popd 'eshell-no-numeric-conversions t) 504(put 'eshell/popd 'eshell-no-numeric-conversions t)
505(put 'eshell/pop 'eshell-filename-arguments t)
503 506
504(defun eshell/dirs (&optional if-verbose) 507(defun eshell/dirs (&optional if-verbose)
505 "Implementation of dirs in Lisp." 508 "Implementation of dirs in Lisp."
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 900b28905b7..2b568a991a2 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -334,6 +334,7 @@ instead."
334 (apply 'eshell-do-ls args))) 334 (apply 'eshell-do-ls args)))
335 335
336(put 'eshell/ls 'eshell-no-numeric-conversions t) 336(put 'eshell/ls 'eshell-no-numeric-conversions t)
337(put 'eshell/ls 'eshell-filename-arguments t)
337 338
338(declare-function eshell-glob-regexp "em-glob" (pattern)) 339(declare-function eshell-glob-regexp "em-glob" (pattern))
339 340
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index c3448de407d..b00b6654cc5 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -307,6 +307,7 @@ Remove (unlink) the FILE(s).")
307 nil)) 307 nil))
308 308
309(put 'eshell/rm 'eshell-no-numeric-conversions t) 309(put 'eshell/rm 'eshell-no-numeric-conversions t)
310(put 'eshell/rm 'eshell-filename-arguments t)
310 311
311(defun eshell/mkdir (&rest args) 312(defun eshell/mkdir (&rest args)
312 "Implementation of mkdir in Lisp." 313 "Implementation of mkdir in Lisp."
@@ -324,6 +325,7 @@ Create the DIRECTORY(ies), if they do not already exist.")
324 nil)) 325 nil))
325 326
326(put 'eshell/mkdir 'eshell-no-numeric-conversions t) 327(put 'eshell/mkdir 'eshell-no-numeric-conversions t)
328(put 'eshell/mkdir 'eshell-filename-arguments t)
327 329
328(defun eshell/rmdir (&rest args) 330(defun eshell/rmdir (&rest args)
329 "Implementation of rmdir in Lisp." 331 "Implementation of rmdir in Lisp."
@@ -340,6 +342,7 @@ Remove the DIRECTORY(ies), if they are empty.")
340 nil)) 342 nil))
341 343
342(put 'eshell/rmdir 'eshell-no-numeric-conversions t) 344(put 'eshell/rmdir 'eshell-no-numeric-conversions t)
345(put 'eshell/rmdir 'eshell-filename-arguments t)
343 346
344(defvar no-dereference) 347(defvar no-dereference)
345 348
@@ -524,6 +527,7 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
524 eshell-mv-overwrite-files)))) 527 eshell-mv-overwrite-files))))
525 528
526(put 'eshell/mv 'eshell-no-numeric-conversions t) 529(put 'eshell/mv 'eshell-no-numeric-conversions t)
530(put 'eshell/mv 'eshell-filename-arguments t)
527 531
528(defun eshell/cp (&rest args) 532(defun eshell/cp (&rest args)
529 "Implementation of cp in Lisp." 533 "Implementation of cp in Lisp."
@@ -561,6 +565,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.")
561 eshell-cp-overwrite-files preserve))) 565 eshell-cp-overwrite-files preserve)))
562 566
563(put 'eshell/cp 'eshell-no-numeric-conversions t) 567(put 'eshell/cp 'eshell-no-numeric-conversions t)
568(put 'eshell/cp 'eshell-filename-arguments t)
564 569
565(defun eshell/ln (&rest args) 570(defun eshell/ln (&rest args)
566 "Implementation of ln in Lisp." 571 "Implementation of ln in Lisp."
@@ -593,6 +598,7 @@ with `--symbolic'. When creating hard links, each TARGET must exist.")
593 eshell-ln-overwrite-files)))) 598 eshell-ln-overwrite-files))))
594 599
595(put 'eshell/ln 'eshell-no-numeric-conversions t) 600(put 'eshell/ln 'eshell-no-numeric-conversions t)
601(put 'eshell/ln 'eshell-filename-arguments t)
596 602
597(defun eshell/cat (&rest args) 603(defun eshell/cat (&rest args)
598 "Implementation of cat in Lisp. 604 "Implementation of cat in Lisp.
@@ -645,6 +651,7 @@ Concatenate FILE(s), or standard input, to standard output.")
645 (setq eshell-ensure-newline-p nil)))) 651 (setq eshell-ensure-newline-p nil))))
646 652
647(put 'eshell/cat 'eshell-no-numeric-conversions t) 653(put 'eshell/cat 'eshell-no-numeric-conversions t)
654(put 'eshell/cat 'eshell-filename-arguments t)
648 655
649;; special front-end functions for compilation-mode buffers 656;; special front-end functions for compilation-mode buffers
650 657
@@ -927,6 +934,8 @@ Summarize disk usage of each FILE, recursively for directories.")
927 (eshell-print (concat (eshell-du-size-string size) 934 (eshell-print (concat (eshell-du-size-string size)
928 "total\n")))))))) 935 "total\n"))))))))
929 936
937(put 'eshell/du 'eshell-filename-arguments t)
938
930(defvar eshell-time-start nil) 939(defvar eshell-time-start nil)
931 940
932(defun eshell-show-elapsed-time () 941(defun eshell-show-elapsed-time ()
@@ -1029,6 +1038,7 @@ Show wall-clock time elapsed during execution of COMMAND.")
1029 nil) 1038 nil)
1030 1039
1031(put 'eshell/diff 'eshell-no-numeric-conversions t) 1040(put 'eshell/diff 'eshell-no-numeric-conversions t)
1041(put 'eshell/diff 'eshell-filename-arguments t)
1032 1042
1033(defvar locate-history-list) 1043(defvar locate-history-list)
1034 1044
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 61c0ebc71d0..92cac612d4c 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -1304,27 +1304,36 @@ messages, and errors."
1304 "Insert Lisp OBJECT, using ARGS if a function." 1304 "Insert Lisp OBJECT, using ARGS if a function."
1305 (catch 'eshell-external ; deferred to an external command 1305 (catch 'eshell-external ; deferred to an external command
1306 (let* ((eshell-ensure-newline-p (eshell-interactive-output-p)) 1306 (let* ((eshell-ensure-newline-p (eshell-interactive-output-p))
1307 (result 1307 (result
1308 (if (functionp object) 1308 (if (functionp object)
1309 (progn 1309 (progn
1310 (setq eshell-last-arguments args 1310 (setq eshell-last-arguments args
1311 eshell-last-command-name 1311 eshell-last-command-name
1312 (concat "#<function " (symbol-name object) ">")) 1312 (concat "#<function " (symbol-name object) ">"))
1313 ;; if any of the arguments are flagged as numbers 1313 (let ((numeric (not (get object
1314 ;; waiting for conversion, convert them now 1314 'eshell-no-numeric-conversions)))
1315 (unless (get object 'eshell-no-numeric-conversions) 1315 (fname-args (get object 'eshell-filename-arguments)))
1316 (while args 1316 (when (or numeric fname-args)
1317 (let ((arg (car args))) 1317 (while args
1318 (if (and (stringp arg) 1318 (let ((arg (car args)))
1319 (> (length arg) 0) 1319 (cond ((and numeric (stringp arg) (> (length arg) 0)
1320 (not (text-property-not-all 1320 (text-property-any 0 (length arg)
1321 0 (length arg) 'number t arg))) 1321 'number t arg))
1322 (setcar args (string-to-number arg)))) 1322 ;; If any of the arguments are
1323 (setq args (cdr args)))) 1323 ;; flagged as numbers waiting for
1324 (eshell-apply object eshell-last-arguments)) 1324 ;; conversion, convert them now.
1325 (setq eshell-last-arguments args 1325 (setcar args (string-to-number arg)))
1326 eshell-last-command-name "#<Lisp object>") 1326 ((and fname-args (stringp arg)
1327 (eshell-eval object)))) 1327 (string-equal arg "~"))
1328 ;; If any of the arguments match "~",
1329 ;; prepend "./" to treat it as a
1330 ;; regular file name.
1331 (setcar args (concat "./" arg)))))
1332 (setq args (cdr args)))))
1333 (eshell-apply object eshell-last-arguments))
1334 (setq eshell-last-arguments args
1335 eshell-last-command-name "#<Lisp object>")
1336 (eshell-eval object))))
1328 (if (and eshell-ensure-newline-p 1337 (if (and eshell-ensure-newline-p
1329 (save-excursion 1338 (save-excursion
1330 (goto-char eshell-last-output-end) 1339 (goto-char eshell-last-output-end)
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index 1bfab23c220..fdb77d32265 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -259,6 +259,7 @@ Adds the given PATH to $PATH.")
259 (eshell-printn dir))))) 259 (eshell-printn dir)))))
260 260
261(put 'eshell/addpath 'eshell-no-numeric-conversions t) 261(put 'eshell/addpath 'eshell-no-numeric-conversions t)
262(put 'eshell/addpath 'eshell-filename-arguments t)
262 263
263(defun eshell-script-interpreter (file) 264(defun eshell-script-interpreter (file)
264 "Extract the script to run from FILE, if it has #!<interp> in it. 265 "Extract the script to run from FILE, if it has #!<interp> in it.