(tramp-run-real-handler #'expand-file-name (list name))
;; Dissect NAME.
(with-parsed-tramp-file-name name nil
+ ;; Tilde expansion shall be possible also for quoted localname.
+ (when (string-prefix-p "~" (file-name-unquote localname))
+ (setq localname (file-name-unquote localname)))
;; If there is a default location, expand tilde.
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
- localname)
+ localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
hname)
(tramp-run-real-handler #'expand-file-name (list name)))
(unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
(setq localname (concat "~/" localname)))
+ ;; Tilde expansion shall be possible also for quoted localname.
+ (when (string-prefix-p "~" (file-name-unquote localname))
+ (setq localname (file-name-unquote localname)))
;; Tilde expansion if necessary. This needs a shell which
;; groks tilde expansion! The function `tramp-find-shell' is
;; supposed to find such a shell on the remote host. Please
(tramp-run-real-handler #'expand-file-name (list name))
;; Dissect NAME.
(with-parsed-tramp-file-name name nil
+ ;; Tilde expansion shall be possible also for quoted localname.
+ (when (string-prefix-p "~" (file-name-unquote localname))
+ (setq localname (file-name-unquote localname)))
;; Tilde expansion if necessary.
(when (string-match
(tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
;; but to the root home directory.
(when (tramp-string-empty-or-nil-p localname)
(setq localname "~"))
+ ;; Tilde expansion shall be possible also for quoted localname.
+ (when (string-prefix-p "~" (file-name-unquote localname))
+ (setq localname (file-name-unquote localname)))
(unless (file-name-absolute-p localname)
(setq localname (format "~%s/%s" user localname)))
(when (string-match
(with-parsed-tramp-file-name name nil
(unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
(setq localname (concat "/" localname)))
+ ;; Tilde expansion shall be possible also for quoted localname.
+ (when (string-prefix-p "~" (file-name-unquote localname))
+ (setq localname (file-name-unquote localname)))
;; Expand tilde. Usually, the methods applying this handler do
;; not support tilde expansion. But users could declare a
;; respective connection property. (Bug#53847)
(should (string-equal (expand-file-name local dir) dir))
(should (string-equal (expand-file-name (concat dir local)) dir)))))
+;; The following test is inspired by Bug#65685.
+(ert-deftest tramp-test05-expand-file-name-tilde ()
+ "Check `expand-file-name'."
+ (skip-unless (tramp--test-enabled))
+ (skip-unless (not (tramp--test-ange-ftp-p)))
+
+ (let ((dir (file-remote-p ert-remote-temporary-file-directory))
+ (tramp-tolerate-tilde t))
+ (should (string-equal (expand-file-name (concat dir "~"))
+ (expand-file-name (concat dir "/:~"))))))
+
(ert-deftest tramp-test06-directory-file-name ()
"Check `directory-file-name'.
This checks also `file-name-as-directory', `file-name-directory',