Commit Graph

26 Commits

Author SHA1 Message Date
Ralf Donau
19aeb71d15 Shell: Use String::join for the command in timing report 2021-08-23 22:46:41 +02:00
Valtteri Koskivuori
b28b4c643e Shell: Avoid a needless loop in builtin_time()
Not performance sensitive, but perhaps a bit neater? :^)
2021-08-23 22:44:32 +02:00
Andreas Kling
b9ab7a5095 Shell: Support time -n <iterations>
You can now specify a number of iterations when timing a command.
The default value is 1 and behaves exactly as before.

If the iteration count is greater than 1, the command will be executed
that many times, and then you get a little timing report afterwards with
the average runtime per iteration, and also the average runtime
excluding the very first iteration. (Excluding the first iteration is
useful when it's slowed down by cold caches, etc.)

This is something I've been doing manually forever (running `time foo`
and then eyeballing the results to headmath an average) and this makes
that whole process so much nicer. :^)
2021-08-23 20:15:14 +02:00
TheFightingCatfish
72e661b542 Shell: Add unalias builtin
Add shell unalias builtin to remove aliases
2021-07-13 11:57:11 +04:30
Daniel Bertalan
e32692ea68 Shell: Use correct printf format string for size_t 2021-07-08 10:11:00 +02:00
Max Wipfli
9b8f35259c AK: Remove the LexicalPath::is_valid() API
Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
2021-06-30 11:13:54 +02:00
Jelle Raaijmakers
00fc0a6cf0 Shell: Make time stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
250f8eccf3 LibCore: Support fine-grained failure behavior for ArgsParser 2021-06-08 11:30:58 +02:00
Andreas Kling
8c3b603da3 Shell: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Ali Mohammad Pur
bda69a5f59 Shell: Replace fprintf(stderr) => warnln() 2021-05-02 19:46:33 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Linus Groh
dbe72fd962 Everywhere: Remove empty line after function body opening curly brace 2021-04-25 20:20:00 +02:00
Ali Mohammad Pur
0d2602c900 Shell: Add a 'kill' builtin that wraps the system's own
Fixes #6578.
2021-04-23 20:27:58 +02:00
Ali Mohammad Pur
95055d3a38 Shell: Add support for jobspecs in fg/bg/disown/wait 2021-04-23 20:27:58 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Gunnar Beutner
1e5a7ca0a7 Shell: Fix how cd handles the path argument
Previously this didn't work:

  $ cd -- /usr
  Invalid path '--'

This path fixes this issue and removes the unnecessary else
branch because we're already using realpath() later on to resolve
relative paths.
2021-04-23 11:33:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
jacob gw
42e63d0a94 Shell: flush stderr and stdout when using builtins
This fixed some tests that were failing.
Thanks @alimpfard for this fix!
2021-04-13 00:02:46 +02:00
jacob gw
cb22a6642d Shell: add type builtin 2021-04-13 00:02:46 +02:00
AnotherTest
5d19509616 Shell: Handle SIGCHLD after sending SIGCONT to job
This fixes `fg` and `bg` causing the shell to go into an infinite loop
of trying to `waitpid` until some current job changes state.

a.k.a. "Fix Shell backgrounding, yet again!" :P
2021-03-31 23:49:26 +02:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
AnotherTest
4f6bf2931c Shell: Make the 'not' builtin return the correct exit code for functions 2021-03-07 10:58:42 +01:00
AnotherTest
e1512d5968 Shell: Skip caching PATH and history load/save when not interactive
Non-interactive shells (i.e. when running scripts) do not need this
functionality, so they are a boatload of wasted time.
This significantly reduces the script startup and shutdown times when
there are lots of executables in PATH or lots of entries in the history.
2021-03-07 10:58:42 +01:00
AnotherTest
50473003be Shell: Add a not builtin
`not` just takes a command, runs it, then negates its exit code (0->1,
non-zero->0).
2021-01-19 08:19:43 +01:00
AnotherTest
cd6e5c064b Shell: Add a builtin that parses its sole argument and dumps its AST
Pretty useful for debugging.
2021-01-19 08:19:43 +01:00
Andreas Kling
c4e2fd8123 Shell: Move to Userland/Shell/ 2021-01-12 12:04:07 +01:00