aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1994-03-21 18:17:27 +0000
committerRichard M. Stallman <[email protected]>1994-03-21 18:17:27 +0000
commit6e2dc7cb71347f6c38bd46f8a2db43c1249a81a2 (patch)
tree24f9691e34f72a7569930ad18c000e0ce14a3434 /lisp
parent83ac6b4598049a3ccb361064d5fc0d0cee7c5705 (diff)
(insert-directory): Quote special shell chars,
aside from wildcards and quoting characters.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 8088ad3d4f..c4eb7f9320 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1990,11 +1990,24 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'."
(let ((default-directory
(if (file-name-absolute-p file)
(file-name-directory file)
- (file-name-directory (expand-file-name file)))))
+ (file-name-directory (expand-file-name file))))
+ (pattern (file-name-nondirectory file))
+ (beg 0))
+ ;; Quote some characters that have special meanings in shells;
+ ;; but don't quote the wildcards--we want them to be special.
+ ;; We also currently don't quote the quoting characters
+ ;; in case people want to use them explicitly to quote
+ ;; wildcard characters.
+ (while (string-match "[ \t\n;<>&|{}()#$]" pattern beg)
+ (setq pattern
+ (concat (substring pattern 0 (match-beginning 0))
+ "\\"
+ (substring pattern (match-beginning 0)))
+ beg (1+ (match-end 0))))
(call-process shell-file-name nil t nil
"-c" (concat insert-directory-program
" -d " switches " "
- (file-name-nondirectory file))))
+ pattern)))
;; SunOS 4.1.3, SVr4 and others need the "." to list the
;; directory if FILE is a symbolic link.
(call-process insert-directory-program nil t nil switches