Subject: bug#20117: 25.0.50; Tramp tests failing on Cygwin

From: Michael Albinus <[email-masked]>
Date: Tue, 17 Mar 2015 20:16:53 +0100

Ken Brown <[email-masked]> writes:

> In case it helps, here's the complete list of Tramp tests that
> currently abort on Cygwin:
>
> tramp-test19-directory-files-and-attributes
> tramp-test30-special-characters
> tramp-test30-special-characters-with-stat
> tramp-test31-utf8
> tramp-test31-utf8-with-stat
>
> I've instrumented all of them and can make the traces available to you
> if it would help.  The four new ones come to more than 9MB, after
> tarring and compressing.

Likely, all of them are caused by the same problem. The traces you have
sent to me for tramp-test19-directory-files-and-attributes indicate a
problem with the marker I have introduced in order to handle apostrophs
in file names properly. I could reproduce it locally with bash and zsh;
other bournish shells like ksh and dash work properly.

The following patch let the construct work in all four investigated
shells for me, could you pls check?

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/tramp/lisp/tramp-sh.el.~master~	2015-03-17 20:12:48.781125579 +0100
--- /home/albinus/src/tramp/lisp/tramp-sh.el	2015-03-17 20:05:35.432048823 +0100
***************
*** 1719,1730 ****
       ;; "-"; this would confuse xargs.  "ls -aQ" might be a solution,
       ;; but it does not work on all remote systems.  Therefore, we
       ;; use \000 as file separator.
!      ;; Apostrophes in the stat output are masked as \037 characters, in
       ;; order to make a proper shell escape of them in file names.
       "cd %s && echo \"(\"; (%s %s -a | "
       "xargs %s -c "
!      "'(\037%%n\037 (\037%%N\037) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \037%%A\037 t %%ie0 -1)'"
!      " -- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/\037/\"/g'); echo \")\"")
      (tramp-shell-quote-argument localname)
      (tramp-get-ls-command vec)
      ;; On systems which have no quoting style, file names with
--- 1719,1730 ----
       ;; "-"; this would confuse xargs.  "ls -aQ" might be a solution,
       ;; but it does not work on all remote systems.  Therefore, we
       ;; use \000 as file separator.
!      ;; Apostrophes in the stat output are masked as \006 characters, in
       ;; order to make a proper shell escape of them in file names.
       "cd %s && echo \"(\"; (%s %s -a | "
       "xargs %s -c "
!      "'(\006%%n\006 (\006%%N\006) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \006%%A\006 t %%ie0 -1)'"
!      " -- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/\006/\"/g'); echo \")\"")
      (tramp-shell-quote-argument localname)
      (tramp-get-ls-command vec)
      ;; On systems which have no quoting style, file names with
***************
*** 1732,1739 ****
      (if (tramp-get-ls-command-with-quoting-style vec)
  	"--quoting-style=shell" "")
      (tramp-get-remote-stat vec)
!     (if (eq id-format 'integer) "%ue0" "\037%U\037")
!     (if (eq id-format 'integer) "%ge0" "\037%G\037"))))
  
  ;; This function should return "foo/" for directories and "bar" for
  ;; files.
--- 1732,1739 ----
      (if (tramp-get-ls-command-with-quoting-style vec)
  	"--quoting-style=shell" "")
      (tramp-get-remote-stat vec)
!     (if (eq id-format 'integer) "%ue0" "\006%U\006")
!     (if (eq id-format 'integer) "%ge0" "\006%G\006"))))
  
  ;; This function should return "foo/" for directories and "bar" for
  ;; files.
--8<---------------cut here---------------end--------------->8---

> Ken

Best regards, Michael.