#1106859 bash: command_not_found_handle break when stdin is invalid

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Jonathan H N Chin
Date:
2025-05-30 15:07:02 UTC
Severity:
normal
#1106859#5
Date:
2025-05-30 14:28:10 UTC
From:
To:
Install `command-not-found` package so that the bash function
`command_not_found_handle` defined in `/etc/bash.bashrc` runs.

Make a command typo: Can be simplified as: `a`
The python handler reports:
```
a: command not found
```

Make a command typo. Can be simplified as: `a </`
The python handler fails with:
```
Fatal Python error: init_sys_streams: <stdin> is a directory, cannot continue
Python runtime state: core initialized
```


I do not know if this is a good fix but editing `/etc/bash.bashrc
so that stdin is redirected from `/dev/null` avoids the failure:

```
	function command_not_found_handle {
	        # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
		   </dev/null /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
		   /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
		else
		   printf "%s: command not found\n" "$1" >&2
		   return 127
		fi
	}
```

My system does not have `/usr/share/command-not-dound/command-not-found`
(and I don't know where it comes from) so I do not know if that has the
same issue and should have a similar fix applied.