From 9afda2fc024211623c5c122459a35e5b8ce70a6c Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Mon, 15 Aug 2022 13:18:08 +0800 Subject: [PATCH 1/2] avoid multiple calling compinit even if it could be in the first call. Signed-off-by: Chen Lihui --- ament_index_python/completion/ament_index-argcomplete.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ament_index_python/completion/ament_index-argcomplete.zsh b/ament_index_python/completion/ament_index-argcomplete.zsh index 68172e0..f5ad5bf 100644 --- a/ament_index_python/completion/ament_index-argcomplete.zsh +++ b/ament_index_python/completion/ament_index-argcomplete.zsh @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -autoload -U +X compinit && compinit -autoload -U +X bashcompinit && bashcompinit +if ! type complete > /dev/null 2>&1; then + autoload -U +X compinit && compinit + autoload -U +X bashcompinit && bashcompinit +fi # Get this scripts directory __ament_index_completion_dir=${0:a:h} From 60cf8236f979e43d6054e695b637bc6b664aa990 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 16 Aug 2022 14:56:52 +0800 Subject: [PATCH 2/2] to separate checking to call compinit and bashcompinit Signed-off-by: Chen Lihui --- ament_index_python/completion/ament_index-argcomplete.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ament_index_python/completion/ament_index-argcomplete.zsh b/ament_index_python/completion/ament_index-argcomplete.zsh index f5ad5bf..13a590f 100644 --- a/ament_index_python/completion/ament_index-argcomplete.zsh +++ b/ament_index_python/completion/ament_index-argcomplete.zsh @@ -12,8 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! type complete > /dev/null 2>&1; then +if ! type compdef > /dev/null 2>&1; then autoload -U +X compinit && compinit +fi + +if ! type complete > /dev/null 2>&1; then autoload -U +X bashcompinit && bashcompinit fi