1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:28:13 +00:00
serenity/Userland
Vetrox 0e26f2657e Shell: Add where builtin
The builtin is based on the behaviour of the z-shell.
Namely it tries to resolve every argument one by one.

When resolving (in the order below) the following results can occur:
  1. The argument is a shell built-in command. Then print it.
  2. The argument is an alias. In this case we print the mapped value.
  3. The argument was found in the `PATH` environment variable.
     In this case we print the resolved absolute path
     and try to find more occurences in the `PATH` environment variable.
  4. None of the above. If no earlier argument got resolved,
     we print the error `{argument} not found`.

If at least one argument got resolved we exit with exit code 0,
otherwise 1.

By not using Core::File to resolve the executable in the environment
but rather using a modified version of the code we print every
matching executable of the given name. This behaviour matches
up with the z-shell.

The builtin has the following flags to modify the behaviour according
to the users needs:
  - `-p --path-only`: This skips the built-in and alias checks
  (step 1 & 2)
  - `-s --follow-symlink`: This follows the symlinks of an executable to
  its symlink-free location.
  - `-w --type`: This displays the type of the found object
  without any additional descriptive information.
2022-12-27 07:25:42 +03:30
..
Applets LibCore: Rename Stream::read_all to read_until_eof 2022-12-12 14:16:42 +01:00
Applications PixelPaint: Erase old active layer boundary when active layer changes 2022-12-26 09:40:11 +01:00
BuggieBox Userland: Add the BuggieBox program 2022-11-26 12:41:47 -07:00
Demos Demos: Remove VirGLDemo 2022-12-26 09:39:20 +01:00
DevTools LibIPC+Everywhere: Change IPC decoders to construct values in-place 2022-12-26 09:36:16 +01:00
DynamicLoader AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
Games Snake: Use a statusbar to display the current and high score 2022-12-23 23:26:21 +01:00
Libraries LibArchive+Utilities: Port ZipOutputStream to Core::Stream 2022-12-27 07:24:07 +03:30
Services WebServer: Use new String type internally as much as possible 2022-12-26 09:38:03 +01:00
Shell Shell: Add where builtin 2022-12-27 07:25:42 +03:30
Utilities LibArchive+Utilities: Port ZipOutputStream to Core::Stream 2022-12-27 07:24:07 +03:30
CMakeLists.txt Userland: Add the BuggieBox program 2022-11-26 12:41:47 -07:00