[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
command_not_found_handle not run when PATH is empty
From: |
Moshe Looks |
Subject: |
command_not_found_handle not run when PATH is empty |
Date: |
Wed, 8 Mar 2023 10:33:48 -0800 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -flto=auto
-ffat-lto-objects -fstack-protector-strong -Wformat
-Werror=format-security -Wall
uname output: Linux xi 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22
14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.1
Patch Level: 16
Release Status: release
Description:
When PATH is empty, the command_not_found_handle function is not
called when a command is not found.
Repeat-By:
> bash -c 'command_not_found_handle() { echo ok; }; no-such-command'
ok
> bash -c 'PATH=; command_not_found_handle() { echo ok; }; no-such-command'
bash: line 1: no-such-command: No such file or directory
I verified this behavior on master as well.
Fix:
--- a/findcmd.c
+++ b/findcmd.c
@@ -632,3 +632,3 @@ find_user_command_in_path (name, path_list, flags, rflagsp)
if (path_list == 0 || *path_list == '\0')
- return (savestring (name)); /* XXX */
+ return ((char *)NULL);
This is very old code and I have no idea what the original intention
was in returning 'name' here or if doing so is still performing useful
work, but the tests pass at least.
Thank you for your attention!
Best, Moshe
- command_not_found_handle not run when PATH is empty,
Moshe Looks <=