Skip to content

Commit

Permalink
Rename shell-split-string to split-string-shell-command
Browse files Browse the repository at this point in the history
* lisp/shell.el (split-string-shell-command):
* doc/lispref/processes.texi (Shell Arguments): Rename from
shell-split-string.
  • Loading branch information
larsmagne committed Jul 15, 2021
1 parent 4fb6cf3 commit 28e7b51
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/lispref/processes.texi
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ protected by @code{shell-quote-argument};
@code{combine-and-quote-strings} is @emph{not} intended to protect
special characters from shell evaluation.

@defun shell-split-string string
@defun split-string-shell-command string
This function splits @var{string} into substrings, respecting double
and single quotes, as well as backslash quoting.

@smallexample
(shell-split-string "ls /tmp/'foo bar'")
(split-string-shell-command "ls /tmp/'foo bar'")
@result{} ("ls" "/tmp/foo bar")
@end smallexample
@end defun
Expand Down
2 changes: 1 addition & 1 deletion etc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ The former is now declared obsolete.
* Lisp Changes in Emacs 28.1

+++
*** New function 'shell-split-string'.
*** New function 'split-string-shell-command'.
This splits a shell string into separate components, respecting single
and double quotes, as well as backslash quoting.

Expand Down
2 changes: 1 addition & 1 deletion lisp/shell.el
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Useful for shells like zsh that has this feature."
(push (mapconcat #'identity (nreverse arg) "") args)))
(cons (nreverse args) (nreverse begins)))))

(defun shell-split-string (string)
(defun split-string-shell-command (string)
"Split STRING (a shell command) into a list of strings.
General shell syntax, like single and double quoting, as well as
backslash quoting, is respected."
Expand Down
12 changes: 6 additions & 6 deletions test/lisp/shell-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
'(("cd" "ba" "") 1 4 7)))))

(ert-deftest shell-tests-split-string ()
(should (equal (shell-split-string "ls /tmp")
(should (equal (split-string-shell-command "ls /tmp")
'("ls" "/tmp")))
(should (equal (shell-split-string "ls '/tmp/foo bar'")
(should (equal (split-string-shell-command "ls '/tmp/foo bar'")
'("ls" "/tmp/foo bar")))
(should (equal (shell-split-string "ls \"/tmp/foo bar\"")
(should (equal (split-string-shell-command "ls \"/tmp/foo bar\"")
'("ls" "/tmp/foo bar")))
(should (equal (shell-split-string "ls /tmp/'foo bar'")
(should (equal (split-string-shell-command "ls /tmp/'foo bar'")
'("ls" "/tmp/foo bar")))
(should (equal (shell-split-string "ls /tmp/'foo\\ bar'")
(should (equal (split-string-shell-command "ls /tmp/'foo\\ bar'")
'("ls" "/tmp/foo\\ bar")))
(should (equal (shell-split-string "ls /tmp/foo\\ bar")
(should (equal (split-string-shell-command "ls /tmp/foo\\ bar")
'("ls" "/tmp/foo bar"))))

;;; shell-tests.el ends here

0 comments on commit 28e7b51

Please sign in to comment.