diff --git a/whatsdirty b/whatsdirty index cb7c0a6..fd9f8f3 100755 --- a/whatsdirty +++ b/whatsdirty @@ -261,8 +261,13 @@ main() { # === Autocomplete Function === handle_autocomplete() { + # Ensure COMP_WORDS and COMP_CWORD are set + if [ -z "${COMP_WORDS+x}" ] || [ -z "${COMP_CWORD+x}" ]; then + return 0 + fi + local cur_word="${COMP_WORDS[COMP_CWORD]}" - + # If we're completing the first argument after 'whatsdirty' if [ ${COMP_CWORD} -eq 1 ]; then # Suggest common directories and saved directory