summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSamer Masterson <samer@samertm.com>2015-04-08 22:31:51 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-04-08 22:31:51 -0400
commitc44f5b046b3f8e9a742c583880ae3a3f78828944 (patch)
tree6f3f09ef706933b30fd212512d86a66f8527151d /test
parent3d78c5578c435c7eb231ff2212aaf85a1b3ed0e5 (diff)
downloademacs-c44f5b046b3f8e9a742c583880ae3a3f78828944.tar.gz
* lisp/eshell: Make backslash a no-op in front of normal chars
Fixes: debbugs:8531 * lisp/eshell/esh-arg.el (eshell-parse-argument-hook): Update comment. (eshell-parse-backslash): Return escaped character after backslash if it is special. Otherwise, if the backslash is not in a quoted string, ignore the backslash and return the character after; if the backslash is in a quoted string, return the backslash and the character after. * test/automated/eshell.el (eshell-test/escape-nonspecial) (eshell-test/escape-nonspecial-unicode) (eshell-test/escape-nonspecial-quoted) (eshell-test/escape-special-quoted): Add tests for new `eshell-parse-backslash' behavior.
Diffstat (limited to 'test')
-rw-r--r--test/automated/eshell.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/automated/eshell.el b/test/automated/eshell.el
index d51355fe5ca..81898db79a7 100644
--- a/test/automated/eshell.el
+++ b/test/automated/eshell.el
@@ -166,6 +166,37 @@ e.g. \"{(+ 1 2)} 3\" => 3"
(eshell-command-result-p "+ 1 2; + $_ 4"
"3\n6\n")))
+(ert-deftest eshell-test/escape-nonspecial ()
+ "Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a
+special character."
+ (with-temp-eshell
+ (eshell-command-result-p "echo he\\llo"
+ "hello\n")))
+
+(ert-deftest eshell-test/escape-nonspecial-unicode ()
+ "Test that \"\\c\" and \"c\" are equivalent when \"c\" is a
+unicode character (unicode characters are nonspecial by
+definition)."
+ (with-temp-eshell
+ (eshell-command-result-p "echo Vid\\éos"
+ "Vidéos\n")))
+
+(ert-deftest eshell-test/escape-nonspecial-quoted ()
+ "Test that the backslash is preserved for escaped nonspecial
+chars"
+ (with-temp-eshell
+ (eshell-command-result-p "echo \"h\\i\""
+ ;; Backslashes are doubled for regexp.
+ "h\\\\i\n")))
+
+(ert-deftest eshell-test/escape-special-quoted ()
+ "Test that the backslash is not preserved for escaped special
+chars"
+ (with-temp-eshell
+ (eshell-command-result-p "echo \"h\\\\i\""
+ ;; Backslashes are doubled for regexp.
+ "h\\\\i\n")))
+
(ert-deftest eshell-test/command-running-p ()
"Modeline should show no command running"
(with-temp-eshell