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

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

[nongnu] elpa/bash-completion 44bc73449e 144/313: Fixes strange behavior


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 44bc73449e 144/313: Fixes strange behavior when completing --.
Date: Sat, 3 Dec 2022 10:59:25 -0500 (EST)

branch: elpa/bash-completion
commit 44bc73449e0a558118dfd58c22303c14d631d1ba
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>

    Fixes strange behavior when completing --.
    
    Completing -- in commands where no completion has been defined used to
    default to file completion, so for example:
    ls --<complete>
    would complete to
    ls --bar
    if there was a file bar in the current directory.
    
    This is because the string to be completed was passed to compgen,
    and when compgen sees --, it just disables parsing of further
    parameters. It didn't happen when using custom completion, because
    bash-completion.el already passed -- in this case.
    
    This change adds the missing -- for default and command completion, to
    avoid issue when completing -- or files starting with -.
    
    Mentioned in issue #13
---
 bash-completion-test.el | 8 ++++----
 bash-completion.el      | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bash-completion-test.el b/bash-completion-test.el
index 7475c2d920..c65414973d 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -321,7 +321,7 @@ garbage
   ;; no custom completion
   (should
    (equal (concat "cd >/dev/null 2>&1 " (expand-file-name "~/test")
-                 " ; compgen -o default worl 2>/dev/null")
+                 " ; compgen -o default -- worl 2>/dev/null")
          (let ((bash-completion-alist nil)
                (default-directory "~/test"))
            (bash-completion-generate-line "hello worl" 7 '("hello" "worl") 1 
nil))))
@@ -356,7 +356,7 @@ garbage
 
   ;; ignore completion function
   (should (equal 
-          "cd >/dev/null 2>&1 /test ; compgen -o default worl 2>/dev/null"
+          "cd >/dev/null 2>&1 /test ; compgen -o default -- worl 2>/dev/null"
           (let ((bash-completion-alist '((nil . ("-F" "__zorg"))))
                 (default-directory "/test"))
             (bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1 
nil)))))
@@ -733,7 +733,7 @@ before calling `bash-completion-dynamic-complete-nocomint'.
    (should (equal
             (list 7 9 '("hell" "hello1" "hello2"))
             (bash-completion-dynamic-complete-nocomint 3 (point))))
-   (should (equal "cd >/dev/null 2>&1 /tmp/test ; compgen -o default he 
2>/dev/null"
+   (should (equal "cd >/dev/null 2>&1 /tmp/test ; compgen -o default -- he 
2>/dev/null"
                   (pop --captured-commands)))))
 
 (ert-deftest bash-completion-single-completion-test ()
@@ -837,7 +837,7 @@ before calling `bash-completion-dynamic-complete-nocomint'.
             '("bin/" "bind ")
             (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))
    (should (equal (concat "cd >/dev/null 2>&1 /tmp/test ; "
-                          "compgen -b -c -a -A function b 2>/dev/null")
+                          "compgen -b -c -a -A function -- b 2>/dev/null")
                   (pop --captured-commands)))))
 
 ;;; bash-completion_test.el ends here
diff --git a/bash-completion.el b/bash-completion.el
index 2e0b470549..0f06fce4b2 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1092,12 +1092,12 @@ completion candidates."
       ((= cword 0)
        ;; a command. let bash expand builtins, aliases and functions
        (setq completion-type 'command)
-       (setq commandline (concat "compgen -b -c -a -A function " stub)))
+       (setq commandline (concat "compgen -b -c -a -A function -- " stub)))
 
       ((not compgen-args)
        ;; no completion configured for this command
        (setq completion-type 'default)
-       (setq commandline (bash-completion-join (list "compgen" "-o" "default" 
stub))))
+       (setq commandline (concat "compgen -o default -- " stub)))
 
       ((or (member "-F" compgen-args) (member "-C" compgen-args))
        ;; custom completion with a function of command



reply via email to

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