Subject: bug#34610: 27.0.50; wdired gets rename file and directory errors when using gls and -F or --classify switch

From: Stefan Kangas <[email-masked]>
Date: Sat, 24 Aug 2019 02:52:08 +0200

"Basil L. Contovounesios" <[email-masked]> writes:

> Jeffrey Spencer <[email-masked]> writes:
>
>> This is the only setup besides -Q default:
>> (setq insert-directory-program "gls" dired-use-ls-dired t)
>> (setq dired-listing-switches "-a --classify -lGhHA  --group-directories-first")
>> "-a --classify -lGhHA  --group-directories-first"
>>
>> Renaming directories doesn't work right due to the --classify (-F)
>> switches using gls on Mac. Also, probably has problems with
>> executables due to adding '*' to the end of the file name but I didn't
>> check. I had to right an advice around wdired-change-mode to remove
>> the switches and then re-add the -F --classify.
>>
>> Here is the errors with just a simple truing to add a character to any directory:
>>
>> Rename ‘/Users/Me/Downloads/youtube/test/k’ to ‘/Users/Me/Downloads/youtube/test/k/’ failed:
>> (file-error Renaming Invalid argument /Users/Me/Downloads/youtube/test/k /Users/Me/Downloads/youtube/test/k/k)
>> Rename ‘/Users/Me/Downloads/youtube/test/kdkd’ to ‘/Users/Me/Downloads/youtube/test/kdkd/’ failed:
>> (file-error Renaming Invalid argument /Users/Me/Downloads/youtube/test/kdkd /Users/Me/Downloads/youtube/test/kdkd/kdkd)
>> Rename ‘/Users/Me/Downloads/youtube/test/l’ to ‘/Users/Me/Downloads/youtube/test/l/’ failed:
>> (file-error Renaming Invalid argument /Users/Me/Downloads/youtube/test/l /Users/Me/Downloads/youtube/test/l/l)
>> Rename ‘/Users/Me/Downloads/youtube/test/kdkd/kdk’ to ‘/Users/Me/Downloads/youtube/test/kdkd/kdk/’ failed:
>> (file-error Renaming Invalid argument /Users/Me/Downloads/youtube/test/kdkd/kdk /Users/Me/Downloads/youtube/test/kdkd/kdk/kdk)
>>
>> 4 rename actions failed
>
> This sounds similar to bug#34915[1], whose fix was recently pushed to
> master[2].  Can you please check whether that also fixes your issue?  If
> so, I will merge the two reports as duplicate.

I'm seeing a failure in the test suite on current master on MacOS that
does not show up on my Debian GNU/Linux system.  The failing test is
the test case for Bug#34915.

(Shell command succeeded with no output)
Connection file
"/var/folders/pj/rhx0gxy15tv3vx6l3mdy0qvm0000gn/T/test-dir-nheUrY/server"
deleted
Press C-c C-c when finished or C-c ESC to abort changes
1 rename actions failed--type ? for details
Connection file
"/var/folders/pj/rhx0gxy15tv3vx6l3mdy0qvm0000gn/T/test-dir-nheUrY/server"
deleted
Test wdired-test-bug34915 backtrace:
  signal(ert-test-failed (((should (equal dir (pop names))) :form (equ
  ert-fail(((should (equal dir (pop names))) :form (equal "bar@" "wbar
  #f(compiled-function () #<bytecode 0x1fec25c0680d>)()
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name wdired-test-bug34915 :documentation "
  ert-run-or-rerun-test(#s(ert--stats :selector (not (or ... ...)) :te
  ert-run-tests((not (or (tag :expensive-test) (tag :unstable))) #f(co
  ert-run-tests-batch((not (or (tag :expensive-test) (tag :unstable)))
  ert-run-tests-batch-and-exit((not (or (tag :expensive-test) (tag :un
  eval((ert-run-tests-batch-and-exit '(not (or (tag :expensive-test) (
  command-line-1(("-L" ":." "-l" "ert" "-l" "lisp/wdired-tests" "--eva
  command-line()
  normal-top-level()
Test wdired-test-bug34915 condition:
    (ert-test-failed
     ((should
       (equal dir
          (pop names)))
      :form
      (equal "bar@" "wbar@")
      :value nil :explanation
      (arrays-of-different-length 4 5 "bar@" "wbar@" first-mismatch-at 0)))
   FAILED  3/5  wdired-test-bug34915 (0.065950 sec)

When I test manually using the flags "-lF", I'm unable to rename a
symlink in wdired and get this error:

   "1 rename actions failed--type ? for details"

I'm using the stock ls from BSD.  Here's the difference in output from
GNU ls and BSD ls on my two machines:

macos$ mkdir tmp
macos$ cd tmp
macos$ touch a
macos$ ln -s a b
macos$ ls -lF
total 8
-rw-r--r--  1 skangas  staff  0 Aug 24 02:41 a
lrwxr-xr-x  1 skangas  staff  1 Aug 24 02:41 b@ -> a
macos$

debian$ mkdir tmp
debian$ cd tmp
debian$ touch a
debian$ ln -s a b
debian$ ls -lF
total 0
-rw-r--r-- 1 skangas skangas 0 Aug 24 02:42 a
lrwxr-xr-x 1 skangas skangas 1 Aug 24 02:42 b -> a
debian$

AFAICT, the difference is that the BSD ls appends an @ character to
the file name, which wdired incorrectly interprets as part of the file
name.

Thanks,
Stefan Kangas