Lisp programs sometimes need to run a shell and give it a command
which contains file names that were specified by the user. These
programs ought to be able to support any valid file name. But the shell
gives special treatment to certain characters, and if these characters
occur in the file name, they will confuse the shell. To handle these
characters, use the function shell-quote-argument
:
Precisely what this function does depends on your operating system. The function is designed to work with the usual shell syntax; if you use an unusual shell, you will need to redefine this function. On MS-DOS, the function returns argument unchanged; while this is not really correct, it is the best one can do, since the MS-DOS shell has no quoting features.
;; This example shows the behavior on GNU and Unix systems. (shell-quote-argument "foo > bar") => "foo\\ \\>\\ bar"
Here's an example of using shell-quote-argument
to construct
a shell command:
(concat "diff -c " (shell-quote-argument oldfile) " " (shell-quote-argument newfile))
Go to the first, previous, next, last section, table of contents.