]> git.corax.cc Git - toolbox/commitdiff
toolbox.sh: Suppress errors in command_not_found_handle()
authorMatthias Kruk <m@m10k.eu>
Thu, 6 Oct 2022 06:21:44 +0000 (15:21 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 6 Oct 2022 06:21:44 +0000 (15:21 +0900)
When the user enters an unknown command, or a script contains an
unknown command, the command_not_found_handle() function provides
suggestions if the unknown command appears to be in a module.
However, because the function does not suppress errors when looking
for modules in the module search paths, it emits errors if any of
the search paths do not exist.

This commit makes the command_not_found_handle() function suppress
errors if any of the module search paths do not exist.

toolbox.sh

index b26729996a19e322be3afbbf42c4475cd0394904..b234b8d74c2904e0d5016961155dbe38e19192bd 100644 (file)
@@ -133,7 +133,7 @@ command_not_found_handle() {
                        if [[ "$command" == "$prefix"* ]]; then
                                candidates["$module_name"]="$module"
                        fi
-               done < <(find -L "$searchpath" -type f -iname "*.sh")
+               done < <(find -L "$searchpath" -type f -iname "*.sh" 2>/dev/null)
        done
 
        if (( ${#candidates[@]} > 0 )); then