unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <m.othacehe@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 30594@debbugs.gnu.org, Michael Albinus <michael.albinus@gmx.de>
Subject: bug#30594: [PATCH] Add coreutils 'ls' support for tramp adb
Date: Sun, 25 Feb 2018 11:48:04 +0100	[thread overview]
Message-ID: <87fu5ppcpn.fsf@gmail.com> (raw)
In-Reply-To: <m2h8q5cr72.fsf@linux-m68k.org>

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]


Hi Andreas,

> Thats `ls -1'.

You're right, I updated my patch. As toybox 'ls' seems to also support
this option, here's an other patch to use 'ls -1' for toybox too.

Thanks,

Mathieu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-coreutils-ls-support-for-tramp-adb.patch --]
[-- Type: text/x-patch, Size: 2213 bytes --]

From 20a0de9436cdac80ac22c1b1efbbaf9654d5bf7f Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <mathieu.othacehe@parrot.com>
Date: Sat, 24 Feb 2018 18:12:36 +0100
Subject: [PATCH] Add coreutils 'ls' support for tramp adb

Support some Android derived systems where 'ls' binary is provided by
GNU Coreutils.

* lisp/net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): Allow '.'
character in file permissions. It indicates an SELinux security
context.
(tramp-adb-get-ls-command): Detect Coreutils version of 'ls'. Force
output on one column and long-iso time style to match the behaviour of
toybox and busybox 'ls' commands.
---
 lisp/net/tramp-adb.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index f5c45f68e9..5489dbe5a5 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -71,7 +71,7 @@ tramp-adb-ls-date-regexp
 
 (defconst tramp-adb-ls-toolbox-regexp
   (concat
-   "^[[:space:]]*\\([-[:alpha:]]+\\)" 	; \1 permissions
+   "^[[:space:]]*\\([-\\.[:alpha:]]+\\)" ; \1 permissions
    "\\(?:[[:space:]]+[[:digit:]]+\\)?"	; links (Android 7/toybox)
    "[[:space:]]*\\([^[:space:]]+\\)"	; \2 username
    "[[:space:]]+\\([^[:space:]]+\\)"	; \3 group
@@ -462,9 +462,15 @@ tramp-adb-get-ls-command
   (with-tramp-connection-property vec "ls"
     (tramp-message vec 5 "Finding a suitable `ls' command")
     (cond
+     ;; Support Android derived systems where "ls" command is provided
+     ;; by GNU Coreutils. Force "ls" to print one column and set
+     ;; time-style to imitate other "ls" flavours.
+     ((tramp-adb-send-command-and-check vec "ls --help | grep coreutils")
+      "ls -1 --time-style=long-iso")
      ;; Can't disable coloring explicitly for toybox ls command.  We
-     ;; must force "ls" to print just one column.
-     ((tramp-adb-send-command-and-check vec "toybox") "env COLUMNS=1 ls")
+     ;; also must force "ls" to print just one column.
+     ((tramp-adb-send-command-and-check vec "toybox")
+      "env COLUMNS=1 ls")
      ;; On CyanogenMod based system BusyBox is used and "ls" output
      ;; coloring is enabled by default.  So we try to disable it when
      ;; possible.
-- 
2.16.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Use-ls-1-to-list-files-with-toybox-ls.patch --]
[-- Type: text/x-patch, Size: 1017 bytes --]

From c41d53965288843285faf1cf9344d6b751eaf1fc Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@gmail.com>
Date: Sun, 25 Feb 2018 11:32:30 +0100
Subject: [PATCH] Use 'ls -1' to list files with toybox ls

* lisp/net/tramp-adb.el (tramp-adb-get-ls-command): Use 'ls -1'
instead of passing COLUMNS=1 env variable. This is isofunctional.
---
 lisp/net/tramp-adb.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 5489dbe5a5..6fe38fb2e5 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -470,7 +470,7 @@ tramp-adb-get-ls-command
      ;; Can't disable coloring explicitly for toybox ls command.  We
      ;; also must force "ls" to print just one column.
      ((tramp-adb-send-command-and-check vec "toybox")
-      "env COLUMNS=1 ls")
+      "ls -1")
      ;; On CyanogenMod based system BusyBox is used and "ls" output
      ;; coloring is enabled by default.  So we try to disable it when
      ;; possible.
-- 
2.16.1


  reply	other threads:[~2018-02-25 10:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 18:06 bug#30594: [PATCH] Add coreutils 'ls' support for tramp adb Mathieu Othacehe
2018-02-24 20:56 ` Michael Albinus
2018-02-24 21:04   ` Michael Albinus
2018-02-25  9:42     ` Mathieu Othacehe
2018-02-25 10:13       ` Andreas Schwab
2018-02-25 10:48         ` Mathieu Othacehe [this message]
2018-02-25 10:57           ` Michael Albinus
2018-02-25 11:18             ` Mathieu Othacehe
2018-02-26 15:52               ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fu5ppcpn.fsf@gmail.com \
    --to=m.othacehe@gmail.com \
    --cc=30594@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).