changeset 6454:f5abd5d777eb

(insert-directory): Quote special shell chars, aside from wildcards and quoting characters.
author Richard M. Stallman <rms@gnu.org>
date Mon, 21 Mar 1994 18:17:27 +0000
parents 974a37e5c414
children 2fc99253fb65
files lisp/files.el
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Mon Mar 21 17:36:52 1994 +0000
+++ b/lisp/files.el	Mon Mar 21 18:17:27 1994 +0000
@@ -1990,11 +1990,24 @@
 	    (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