- (if (eshell-looking-at-backslash-return (point))
- (throw 'eshell-incomplete ?\\)
- (if (and (not (eq (char-after (1+ (point))) ?\\))
- (if eshell-current-quoted
- (memq (char-after (1+ (point)))
- eshell-special-chars-inside-quoting)
- (memq (char-after (1+ (point)))
- eshell-special-chars-outside-quoting)))
- (progn
- (forward-char 2)
- (list 'eshell-escape-arg
- (char-to-string (char-before))))
- ;; allow \\<RET> to mean a literal "\" character followed by a
- ;; normal return, rather than a backslash followed by a line
- ;; continuation (i.e., "\\ + \n" rather than "\ + \\n"). This
- ;; is necessary because backslashes in Eshell are not special
- ;; unless they either precede something special, or precede a
- ;; backslash that precedes something special. (Mainly this is
- ;; done to make using backslash on Windows systems more
- ;; natural-feeling).
- (if (eshell-looking-at-backslash-return (1+ (point)))
- (forward-char))
- (forward-char)
- "\\"))))
+ (when (eshell-looking-at-backslash-return (point))
+ (throw 'eshell-incomplete ?\\))
+ (forward-char 2) ; Move one char past the backslash.
+ ;; If the char is in a quote, backslash only has special meaning
+ ;; if it is escaping a special char.
+ (if eshell-current-quoted
+ (if (memq (char-before) eshell-special-chars-inside-quoting)
+ (list 'eshell-escape-arg (char-to-string (char-before)))
+ (concat "\\" (char-to-string (char-before))))
+ (if (memq (char-before) eshell-special-chars-outside-quoting)
+ (list 'eshell-escape-arg (char-to-string (char-before)))
+ (char-to-string (char-before))))))