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

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

[nongnu] elpa/bash-completion ae6560fe89: Append / to directories under


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion ae6560fe89: Append / to directories under Bash 4.2 and 4.3.
Date: Wed, 15 Mar 2023 15:59:48 -0400 (EDT)

branch: elpa/bash-completion
commit ae6560fe897ab6fcc0b1c4aac1ac084be5bc632e
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <stephane@fuzzy.zia>

    Append / to directories under Bash 4.2 and 4.3.
    
    Before this change, appending / to directories was turned off under
    Bash4.2 and Bash4.3, because post-filtering of results is implemented
    using a feature introduced in Bash4.4.
    
    This change introduces backward-compatibility logic to support
    post-filtering of results under Bash4.2 and Bash4.3 which requires
    mkfifo.
    
    fixes issue #66
---
 README.md                                |  3 ---
 bash-completion.el                       | 18 +++++++++++-------
 test/bash-completion-integration-test.el | 20 ++++++--------------
 3 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index b51234e66d..ca82aa4cb1 100644
--- a/README.md
+++ b/README.md
@@ -128,7 +128,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
 bash-completion.el is known to work with Bash 4.2 and later and Bash
 5, on Emacs, starting with version 25.3, under Linux and OSX. 
 
-Support for Bash 4.2 and 4.3 is incomplete: appending / to directories
-doesn't work. Consider upgrading to at least Bash 4.4.
-
 [new_issue]: https://github.com/szermatt/emacs-bash-completion/issues/new
diff --git a/bash-completion.el b/bash-completion.el
index caddeac1be..d94f01d469 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -101,9 +101,6 @@
 
 ;; bash-completion.el is known to work with Bash 4.2 and later and
 ;; Bash 5, on Emacs, starting with version 25.3, under Linux and OSX.
-;;
-;; Support for Bash 4.2 and 4.3 is incomplete: appending / to
-;; directories doesn't work. Consider upgrading to at least Bash 4.4.
 
 ;;; History:
 
@@ -384,14 +381,21 @@ returned."
    (concat "function __ebcfixdirs {"
            "  local l; "
            "  while read l; do "
+           "    [[ \"$l\" = \"==eof==\" ]] && break;"
            "    if [[ -d \"${l/#\~/$HOME}\" ]]; then echo \"$l/\"; else echo 
\"$l\"; fi; "
            "  done; "
            "} ; case \"${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}\" in "
            "  4.[23]) function __ebcompgen {"
-           ;; __ebcfixdirs cannot safely be applied to post-process
-           ;; the output of compgen in the general case because wait
-           ;; $! doesn't work with <(..) before version 4.4.
-           "    compgen \"$@\" 2>/dev/null; "
+           ;; wait cannot be used with <(...) before Bash 4.4.
+           "    local fd p=$(mktemp -u);"
+           "    mkfifo \"$p\";"
+           "    exec {fd}<>\"$p\";"
+           "    rm \"$p\";"
+           "    { __ebcfixdirs & } <&$fd 2>/dev/null;"
+           "    local pid=$!;"
+           "    compgen \"$@\" >&$fd 2>/dev/null; echo ==eof==>&$fd;"
+           "    wait $pid 2>/dev/null;"
+           "    exec {fd}>&-;"
            "  } ;;"
            "  *) function __ebcompgen {"
            ;; __ebcfixdirs post-processes the output to add / after
diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index 750687597a..c233f4dcb8 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -185,7 +185,6 @@ for testing completion."
       (with-temp-file (expand-file-name "bashrc" test-env-dir)
         ;; Disable ZSH warning under MacOS Catalina
         (insert "export BASH_SILENCE_DEPRECATION_WARNING=1") 
-        (insert "export PATH=/bin\n")
         (insert (format "cd '%s'\n" test-env-dir))
         (insert bashrc)
         (insert "\n")
@@ -207,11 +206,6 @@ for testing completion."
   (when test-env-dir
     (delete-directory test-env-dir 'recursive)))
 
-(defun bash-completion_test-post-44-p ()
-  (not (string-match-p
-        "version 4\\.[0123].*"
-        (shell-command-to-string (concat bash-completion-prog " -version")))))
-
 (defun bash-completion_test-equal-any-order (expected actual)
   "Compare a sorted list of string EXPECTED with ACTUAL.
 
@@ -378,22 +372,20 @@ across Emacs version."
 (ert-deftest bash-completion-integration-space ()
   ;; While completion generally works with Bash 4.0, 4.1, 4.2 and 4.3,
   ;; bash-completion.el appending / to directories doesn't work.
-  (skip-unless (bash-completion_test-post-44-p))
   (bash-completion_test-with-shell-harness
    ""
    t ; bash-completion-use-separate-processes
    (bash-completion_test-test-spaces)))
 
 (ert-deftest bash-completion-integration-space-and-prog-completion ()
-  (skip-unless (bash-completion_test-post-44-p))
+  (skip-unless (and bash-completion_test-setup-completion
+                    (not (zerop (length 
bash-completion_test-setup-completion)))))
   ;; Recent version of bash completion define a completion for ls. This
   ;; test makes sure that it works.
-  (when (and bash-completion_test-setup-completion
-             (not (zerop (length bash-completion_test-setup-completion))))
-    (bash-completion_test-with-shell-harness
-     (concat "source " bash-completion_test-setup-completion "\n")
-     t ; bash-completion-use-separate-processes
-     (bash-completion_test-test-spaces))))
+  (bash-completion_test-with-shell-harness
+   (concat "source " bash-completion_test-setup-completion "\n")
+   t ; bash-completion-use-separate-processes
+   (bash-completion_test-test-spaces)))
   
 (defun bash-completion_test-test-spaces ()
    (make-directory "my dir1/my dir2" 'parents)



reply via email to

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