From 40714e3da88198ea96c4756a8607c758527b8e99 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 17 Oct 2012 20:50:15 -0700 Subject: [PATCH] * dired.el (dired-sort-toggle): Some ls implementations only allow a single option string. Fixes: debbugs:12666 --- lisp/ChangeLog | 3 +++ lisp/dired.el | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 398b058a874..e799ead207b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-10-18 Glenn Morris + * dired.el (dired-sort-toggle): Some ls implementations only allow + a single option string. (Bug#12666) + * minibuffer.el (completion-cycle-threshold): Doc fix. 2012-10-17 Kenichi Handa diff --git a/lisp/dired.el b/lisp/dired.el index a17e1805339..a4bc16caebf 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3546,8 +3546,15 @@ With a prefix argument, edit the current listing switches instead." (setq dired-actual-switches (replace-match "" t t dired-actual-switches 3)))) ;; Now, if we weren't sorting by date before, add the -t switch. + ;; Some simple-minded ls implementations (eg ftp servers) only + ;; allow a single option string, so try not to add " -t" if possible. (unless sorting-by-date - (setq dired-actual-switches (concat dired-actual-switches " -t")))) + (setq dired-actual-switches + (concat dired-actual-switches + (if (string-match-p "\\`-[[:alnum:]]+\\'" + dired-actual-switches) + "t" + " -t"))))) (dired-sort-set-mode-line) (revert-buffer)) -- 2.39.2