emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/detached 52140bc17f: Add support for OSX tail


From: ELPA Syncer
Subject: [elpa] externals/detached 52140bc17f: Add support for OSX tail
Date: Tue, 15 Nov 2022 08:57:32 -0500 (EST)

branch: externals/detached
commit 52140bc17f0e0cc5edc4c05d096d847f9537b3d9
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Add support for OSX tail
    
    Strangely the tail of unixes has diverted. OSX tail does not have
    support for "--" or long args. But the same functionality is hidden
    under short args.
    
    `--follow=name`, `--lines=` and `--retry` is not supported by OSX tail.
    
    - `--lines=` is replaced by the short alternative `-n`
    
    >      -n, --lines=[+]NUM
    >             output the last NUM lines, instead of the last 10; or use
    >             -n +NUM to output starting with line NUM
    >
    > tail(1) — Linux manual page
    
    - `--follow=name` and `--retry` by `-F`
    
    >      -F     same as --follow=name --retry
    >
    > tail(1) — Linux manual page
    
    There is some trade off regarding descriptiveness but OSX support
    seams preferable - OSX user
---
 detached.el           | 10 ++++++----
 test/detached-test.el | 23 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/detached.el b/detached.el
index a2e32467dd..e2c22f4db7 100644
--- a/detached.el
+++ b/detached.el
@@ -1129,8 +1129,9 @@ Optionally CONCAT the command return command into a 
string."
 Optionally CONCAT the command return command into a string."
   (detached-connection-local-variables
    (let* ((log (detached--session-file session 'log t))
-          (tail-command `(,detached-tail-program "--follow=name" "--retry"
-                                                 ,(concat "--lines=" 
detached-session-context-lines)
+          (tail-command `(,detached-tail-program "-F"
+                                                 "-n"
+                                                 ,(number-to-string 
detached-session-context-lines)
                                                  ,log)))
      (cond ((eq 'create detached-session-mode)
             (detached--dtach-command session))
@@ -1167,7 +1168,7 @@ Optionally CONCAT the command return command into a 
string."
          (if concat
              (string-join
               `(,(when detached-show-session-context
-                   (format  "%s --lines=%s %s;" detached-tail-program 
detached-session-context-lines log))
+                   (format  "%s -n %s %s;" detached-tail-program 
detached-session-context-lines log))
                 ,detached-dtach-program
                 ,dtach-arg
                 ,socket
@@ -1175,7 +1176,8 @@ Optionally CONCAT the command return command into a 
string."
               " ")
            (append
             (when detached-show-session-context
-              `(,detached-tail-program ,(format "--lines=%s" 
detached-session-context-lines)
+              `(,detached-tail-program "-n"
+                                       ,(number-to-string 
detached-session-context-lines)
                                        ,(concat log ";")))
             `(,detached-dtach-program ,dtach-arg ,socket "-r" "none")))
        (if concat
diff --git a/test/detached-test.el b/test/detached-test.el
index 6834e91a27..2ad733e19f 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -87,6 +87,24 @@
 
 ;;;;; Other
 
+ (ert-deftest detached-test-tail-command ()
+   (detached-test--with-temp-database
+    (cl-letf* ((detached-tail-program "tail")
+               (session (detached-create-session "ls -la"))
+               (detached-show-session-context t)
+               (detached-session-context-lines 20)
+               ((symbol-function #'detached-create-session)
+                (lambda (_)
+                  session)))
+      (let* ((log (detached--session-file session 'log t))
+             (expected `(,detached-tail-program
+                         "-F" "-n" ,(number-to-string 
detached-session-context-lines)
+                         ,log))
+             (expected-concat (string-join expected " ")))
+        (let ((detached-session-mode 'create-and-attach))
+          (should (equal expected (detached--tail-command session)))
+          (should (equal expected-concat (detached--tail-command session 
t))))))))
+
 (ert-deftest detached-test-dtach-command ()
   (detached-test--with-temp-database
    (cl-letf* ((detached-dtach-program "dtach")
@@ -117,11 +135,12 @@
         (let* ((detached-session-mode 'attach)
                        (log (detached--session-file session 'log t))
                        (expected `(,detached-tail-program
-                                               ,(format "--lines=%s" 
detached-session-context-lines)
+                        "-n"
+                        ,(number-to-string detached-session-context-lines)
                                                ,(format "%s;" log)
                                                ,detached-dtach-program "-a" 
,(detached--session-file session 'socket t) "-r" "none"))
                        (expected-concat (format "%s %s; %s -a %s -r none"
-                                                                        
(format "%s --lines=%s" detached-tail-program detached-session-context-lines)
+                                     (format "%s -n %s" detached-tail-program 
detached-session-context-lines)
                                                                         log
                                                                         
detached-dtach-program
                                                                         
(detached--session-file session 'socket t))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]