Skip to content

Commit c50eab9

Browse files
akinomyogascop
authored andcommitted
docs(README): update requirements on "command_not_found_handle"
1 parent e9b9688 commit c50eab9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,22 @@ A. Probably because the database is being queried every time and this uses a
310310
**Q. bash-completion interferes with my `command_not_found_handle` function
311311
(or the other way around)!**
312312

313-
A. If your `command_not_found_handle` function is not intended to
314-
address (possibly missing) commands invoked during bash
315-
programmable completion functions, you can account for this
316-
in the function by, for example, testing if the `$COMP_LINE`
317-
variable is set and taking appropriate action, typically returning
318-
early and silently with success.
313+
A. If your `command_not_found_handle` function is not intended to address
314+
(possibly missing) commands invoked during bash programmable completion
315+
functions, you can account for this in the function by, for example, testing
316+
if the `$COMP_POINT` variable is set and taking appropriate action,
317+
typically returning early and silently with success. For keybindings with
318+
`bind -x`, you may additionally want to check if the variable
319+
`$READLINE_POINT` is set to skip the action.
320+
321+
> [!Note]
322+
> We recommended checking whether `COMP_LINE` is *set*, which still works if
323+
> properly done with e.g. `[[ ${COMP_LINE+set} ]]`. However, if you have
324+
> been checking if `COMP_LINE` is *non-empty* with `[[ ${COMP_LINE:-} ]]`,
325+
> it may fail to detect programmable completion with the setting `complete
326+
> -E` (in Bash >= 4.1) because `COMP_LINE` can be empty in this context. It
327+
> is safer to test `COMP_POINT` as one does not need to care about the
328+
> differences between the set and non-empty states of variables.
319329
320330
**Q. Can tab completion be made even easier?**
321331

0 commit comments

Comments
 (0)