diff --git a/Userland/Libraries/LibCore/DirIterator.cpp b/Userland/Libraries/LibCore/DirIterator.cpp index 11758a328c..527c36b579 100644 --- a/Userland/Libraries/LibCore/DirIterator.cpp +++ b/Userland/Libraries/LibCore/DirIterator.cpp @@ -97,6 +97,9 @@ String DirIterator::next_full_path() String find_executable_in_path(String filename) { + if (filename.is_empty()) + return {}; + if (filename.starts_with('/')) { if (access(filename.characters(), X_OK) == 0) return filename; diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 2ef26a999a..f6ae701c11 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -227,7 +227,7 @@ int Shell::builtin_type(int argc, const char** argv) // check if its an executable in PATH auto fullpath = Core::find_executable_in_path(command); - if (!fullpath.is_null()) { + if (!fullpath.is_empty()) { printf("%s is %s\n", command, escape_token(fullpath).characters()); continue; } diff --git a/Userland/Utilities/which.cpp b/Userland/Utilities/which.cpp index 42183261f8..f0abc156c3 100644 --- a/Userland/Utilities/which.cpp +++ b/Userland/Utilities/which.cpp @@ -21,7 +21,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto fullpath = Core::find_executable_in_path(filename); - if (fullpath.is_null()) { + if (fullpath.is_empty()) { warnln("no '{}' in path", filename); return 1; }