From 2cf62de30899d4ecd9321f59b80b8da441c3e897 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Sun, 3 Jan 2010 19:01:56 +0100 Subject: [PATCH] protect against error when used in history context (COMP_CWORD=0) --- bash_completion | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index b2ad64a3..05f12936 100644 --- a/bash_completion +++ b/bash_completion @@ -326,7 +326,12 @@ _get_cword() # COMP_WORDBREAKS. # @see _get_cword() # -_get_pword() { _get_cword "${@:-}" 1; } +_get_pword() +{ + if [ $COMP_CWORD -ge 1 ]; then + _get_cword "${@:-}" 1; + fi +} # If the word-to-complete contains a colon (:), left-trim COMPREPLY items with