(defun eshell-glob-p (pattern)
"Return non-nil if PATTERN has any special glob characters."
- (string-match (eshell-glob-chars-regexp) pattern))
+ ;; "~" is an infix globbing character, so one at the start of a glob
+ ;; must be a literal.
+ (let ((start (if (string-prefix-p "~" pattern) 1 0)))
+ (string-match (eshell-glob-chars-regexp) pattern start)))
(defun eshell-glob-convert-1 (glob &optional last)
"Convert a GLOB matching a single element of a file name to regexps.
(should (equal (eshell-get-path 'literal)
expected-path))))
+(ert-deftest esh-util-test/split-filename/absolute ()
+ "Test splitting an absolute filename."
+ (should (equal (eshell-split-filename "/foo/bar/file.txt")
+ '("/" "foo/" "bar/" "file.txt"))))
+
+(ert-deftest esh-util-test/split-filename/relative ()
+ "Test splitting a relative filename."
+ (should (equal (eshell-split-filename "foo/bar/file.txt")
+ '("foo/" "bar/" "file.txt"))))
+
+(ert-deftest esh-util-test/split-filename/user ()
+ "Test splitting a user filename."
+ (should (equal (eshell-split-filename "~/file.txt")
+ '("~/" "file.txt")))
+ (should (equal (eshell-split-filename "~user/file.txt")
+ '("~user/" "file.txt"))))
+
+(ert-deftest esh-util-test/split-filename/remote-absolute ()
+ "Test splitting a remote absolute filename."
+ (skip-unless (eshell-tests-remote-accessible-p))
+ (let ((remote (file-remote-p ert-remote-temporary-file-directory)))
+ (should (equal (eshell-split-filename (format "%s/foo/bar/file.txt" remote))
+ `(,remote "/" "foo/" "bar/" "file.txt")))))
+
+(ert-deftest esh-util-test/split-filename/remote-relative ()
+ "Test splitting a remote relative filename."
+ (skip-unless (eshell-tests-remote-accessible-p))
+ (let ((remote (file-remote-p ert-remote-temporary-file-directory)))
+ (should (equal (eshell-split-filename (format "%sfoo/bar/file.txt" remote))
+ `(,remote "foo/" "bar/" "file.txt")))))
+
+(ert-deftest esh-util-test/split-filename/remote-user ()
+ "Test splitting a remote user filename."
+ (skip-unless (eshell-tests-remote-accessible-p))
+ (let ((remote (file-remote-p ert-remote-temporary-file-directory)))
+ (should (equal (eshell-split-filename (format "%s~/file.txt" remote))
+ `(,remote "~/" "file.txt")))
+ (should (equal (eshell-split-filename (format "%s~user/file.txt" remote))
+ `(,remote "~user/" "file.txt")))))
+
;;; esh-util-tests.el ends here