[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 520503455d: fix: Keep existing trap when i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 520503455d: fix: Keep existing trap when installing trap __ebctrap DEBUG |
Date: |
Thu, 26 Jun 2025 19:00:59 -0400 (EDT) |
branch: elpa/bash-completion
commit 520503455d0ad762faa75b88501cccc71786343d
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
fix: Keep existing trap when installing trap __ebctrap DEBUG
Before this change, any DEBUG trap installed before bash completion was
overwritten. This change adds to the existing trap, so if the trap
is:
trap -- '__somefunc' DEBUG
the complete trap ends up being:
trap -- '__somefunc; __ebctrap' DEBUG
fixes #78
---
bash-completion.el | 8 +++++++-
test/bash-completion-integration-test.el | 26 ++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/bash-completion.el b/bash-completion.el
index 5a7d9ff8fe..4d24b4038c 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1557,7 +1557,13 @@ Return the status code of the command, as a number."
" PROMPT_COMMAND=\"${__ebcp[1]}\";"
" unset __ebcp __ebcret;"
" fi;"
- "} ; trap __ebctrap DEBUG ; function __ebcpre {"
+ "} ; "
+ "if [[ \"$(trap -p DEBUG)\" =~ trap\\ --\\ \\'(.*)\\'\\ DEBUG
]]; then "
+ " trap \"${BASH_REMATCH[1]}; __ebctrap\" DEBUG; "
+ "else "
+ " trap __ebctrap DEBUG; "
+ "fi; "
+ "function __ebcpre {"
" __ebcor=${__ebcor:-$?}; "
" set +x; set +o emacs; set +o vi;"
" echo \"==emacs==bash=${BASH_VERSION}==.\";"
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index 02c24ecc0d..2364cf6d0f 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -960,4 +960,30 @@ $ ")))))
"101\n"
"$ ")))))
+(ert-deftest bash-completion-keep-existing-trap ()
+ (bash-completion_test-with-shell-harness
+ (concat ; .bashrc
+ "calls=0\n"
+ "function _calltrap {\n"
+ " calls=$((calls+1))\n"
+ "}\n"
+ "trap _calltrap DEBUG\n"
+ "PS1='\$ '")
+ nil
+ (bash-completion_test-send "n=$calls")
+ (bash-completion_test-send "tru" 'complete)
+ (bash-completion_test-send "fals" 'complete)
+ (bash-completion_test-send "[[ $calls -gt $n ]] && echo ok")
+ (bash-completion_test-send "trap -p DEBUG")
+ (should (equal (bash-completion_test-buffer-string)
+ (concat
+ "$ n=$calls\n"
+ "$ true\n"
+ "$ false\n"
+ "$ [[ $calls -gt $n ]] && echo ok\n"
+ "ok\n"
+ "$ trap -p DEBUG\n"
+ "trap -- '_calltrap; __ebctrap' DEBUG\n"
+ "$ ")))))
+
;;; bash-completion-integration-test.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/bash-completion 520503455d: fix: Keep existing trap when installing trap __ebctrap DEBUG,
ELPA Syncer <=