22 Commits
Author SHA1 Message Date
Eduardo Casadei 78085e276d LibShell: Stop reading error source text directly from the source file
Use the saved source text instead of trying to read it directly from the
source file, as the source file may be a relative path and the script
could have changed the current working directory which would make the
path invalid.
2026-11-02 09:33:46 +01:00
Eduardo Casadei 47b533f8d8 LibShell: Save the source text for script files
The function for running a script file already reads its source data
into a buffer, so also set the source text to it.
2026-11-02 09:33:46 +01:00
Eduardo Casadei b2b6f02449 LibShell: Display the source file path on errors
Includes the source file path with line and collumn numbers in the error
messages and also corrects the shown line number to start at 1 instead
of 0.
2026-10-31 22:27:38 +01:00
Eduardo Casadei 5f5db06d12 LibShell: Correctly handle path resolution when changing directory
The correct POSIX behaviour when changing directory is to resolve the
path logically, not following symlinks. Optionally having the -P flag to
resolve the path physically, which follows symlinks.
2026-10-16 09:57:03 +02:00
Ali Mohammad Pur 8b265f7a76 LibShell: Retain continuations when expanding aliases
This broke my `rm -fr foo; echo hi` since I have `alias rm=rm\ -i`.
2026-09-06 19:08:26 -04:00
Ali Mohammad Pur 9ccfb1353d LibShell: Restore suspended job terminal modes 2026-08-27 16:08:33 +02:00
Lucas CHOLLET 0ff1f39b8b Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-20 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2025-10-10 00:02:50 +02:00
Ali Mohammad Pur 350fc07712 LibShell: Don't forcefully make absolute paths relative in builtin_cd
Fixes #26152
2025-08-28 10:58:51 +02:00
Sönke Holz 53d4d65bd1 LibShell: Increase program-aware completion timeout
The old timeout was too low when running in riscv64 QEMU (with TCG).
2025-06-23 21:02:45 +02:00
Ali Mohammad Pur 8b97210a91 Shell: Don't use uninitialized termios data
1c7233f148 broke this by moving the
initialization later, while still having the shell use the invalid
termios data.
Also, this commit makes it so *only* the init script is run without the
termios populated, as 'Shell -c ...' should still behave like running
the command in the shell.
2025-06-01 01:07:42 +02:00
Lucas CHOLLET 91f8d50ba2 AK: Add the Vector::extend(Span) overload
Note that the two `.span()` added in LibShell just make the copy
explicit. These two calls to `extend` ended up relying on this copy
constructor: `Vector(Vector<T, other_inline_capacity> const& other)`, so
it was never a real move.
2025-03-21 22:45:38 -04:00
Andreas Kling 073b3b992d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.

(cherry picked from commit dd419b5a8df3b9a32478c4a8f0ea9f70334214cd;
amended to update the rest of the system. No conflicts though!)
2024-11-29 16:03:30 -05:00
Ali Mohammad Pur 95df87fbed LibShell: Clear the initial prompt line
This fixes a rendering issue where the first line of the prompt
overwrites a line with "% ...", which leaves the "%" in the terminal
if the prompt starts with "\n".
2024-11-18 21:00:53 +01:00
Ali Mohammad Pur 352f879993 Shell: Add the 'command' builtin 2024-11-10 19:22:14 +01:00
Ninad Sachania b9e387ed6d LibShell/Builtin: Add a blank line before the timing report 2024-11-07 07:24:24 -05:00
Ninad Sachania 7d1d5450a4 LibShell/Builtin: Add spaces to make the output more consistent 2024-11-07 07:24:24 -05:00
Ali Mohammad Pur 808c98511b LibShell: Make null_if_unset_or_alternative actually return () if unset
Previously this acted more like "alternative if set or value", which is
completely wrong (based on the POSIX sh definition).
2024-10-09 12:39:08 +02:00
Ali Mohammad Pur 8371f26fae LibShell: Make 'bool' argsparser arguments not take a value 2024-10-09 12:39:08 +02:00
Ali Mohammad Pur abc697b68b LibShell: Avoid UAFs in argsparser_parse
Core::ArgsParser does not copy the arguments anywhere, so all the
strings allocated have to stay alive until the end of the function.
2024-10-09 12:39:08 +02:00
Liav A. 6cd24efcbe Userland: Reduce further the amount of dependencies for LibShellMinimal
To be able to do this, we actually change multiple things:
- We create another subset library from LibCore called LibCoreBasic.
- We force LibLine and LibShellMinimal to use LibCoreMinimal and
  LibCoreBasic and only these, instead of the full version (LibCore).
2024-10-04 10:56:27 +02:00
Liav A. 20982a02d5 Userland: Declare a reduced version of LibShell
As a preparation for the next commit, we now have a reduced version of
LibShell which can be used with BuggieBox. That version will not include
LibSyntax, LibURL or LibCodeComprehension, which are all quite heavy for
BuggieBox to include in its own binary.
2024-10-04 10:56:27 +02:00
Liav A. d46be35f3f Userland: Move Shell code to be in a library directory
This change ensures that users can use LibShell easily understand this
library now, because we have an actual library directory.

In addition to that, we move the test scripts to Tests/LibShell, to
match the usual pattern of putting test-related files in the Tests/
directory.
2024-10-04 10:56:27 +02:00