Commit graph

26 commits

Author SHA1 Message Date
Andreas Kling 08cd75ac4b Kernel: Rename FileDescriptor to FileDescription.
After reading a bunch of POSIX specs, I've learned that a file descriptor
is the number that refers to a file description, not the description itself.
So this patch renames FileDescriptor to FileDescription, and Process now has
FileDescription* file_description(int fd).
2019-06-07 09:36:51 +02:00
Andreas Kling ecb72dd991 Shell: Print the name of each process whose exit status we're reporting. 2019-06-06 11:00:48 +02:00
Andreas Kling 036d808e96 Shell: Check the exit status of all spawned child processes. 2019-06-06 11:00:48 +02:00
Andreas Kling 848044b74c Shell: Separate fd rewirings from redirections.
This was unnecessarily confusing. When we build up a chain of commands
connected by pipes, we now store the file descriptors of each end of
these pipes as rewirings in a vector. The rewirings are then put into
effect by calls to dup2().
2019-06-04 20:36:08 +02:00
Andreas Kling 6b585f9dd7 Shell: Fix an error message incorrectly complaining about lstat() failure.
The syscall used is actually stat(), so let's be correct about that.
2019-05-31 06:07:09 +02:00
Andreas Kling 07c3cc01ec LibC: Move wait-related stuff to <sys/wait.h>. #POSIX 2019-05-30 15:12:09 +02:00
Andreas Kling 96db775ac1 LibC: Add setenv().
If I'm understanding the standard C library correctly, setenv() copies while
putenv() does not. That's really confusing and putenv() basically sucks.
To know which environment variables to free on replacement and which ones to
leave alone, we keep track of the ones malloced by setenv in a side table.

This patch also moves Shell to using setenv() instead of putenv().

Fixes #29.
2019-05-30 03:22:18 +02:00
Robin Burchell 0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00
Robin Burchell 9947ee9566 Shell: Allow * and ? wildcard expansion in arguments
Should also presumably allow for escaping and such, but this is a start.
Fixes #112.
2019-05-28 00:17:39 +02:00
Andreas Kling dd595fe865 Shell: A '>' redirection target should be truncated. 2019-05-26 14:57:12 +02:00
Andreas Kling 0fa098845f Shell: When a command is terminated by a signal, print signal description.
Previously we were only printing the signal number (except for SIGINT.)
2019-05-26 02:35:25 +02:00
Robin Burchell aee99b05a6 Shell: Add append operator (>>)
Fixes #93.
2019-05-26 01:32:05 +02:00
Robin Burchell abb7455163 LibC/Shell: Add unsetenv(), and unset builtin calling it in Shell. 2019-05-16 14:32:09 +02:00
Robin Burchell b2dd12daac LibC: Change putenv (and getenv) to not copy, but directly return the environ values.
This is in keeping with how putenv should function. It does mean that
the shell's export command now leaks, but that's not a difficult fix.

Contributes to #29.
2019-05-16 14:32:09 +02:00
Andreas Kling 3cba2a8a78 Kernel: Add a beep() syscall that beeps the PC speaker.
Hook this up in Terminal so that the '\a' character generates a beep.
Finally emit an '\a' character in the shell line editing code when
backspacing at the start of the line.
2019-05-15 21:40:41 +02:00
Andreas Kling 852d648912 Fix "make clean" not deleting app binaries. 2019-05-13 14:56:18 +02:00
Andreas Kling 43604bf71a LibC+Shell: Make system() actually work.
system() will now fork off a child process and execute the command via
/bin/sh -c. There are probably some things to fix here, but it's a start.
2019-05-13 04:52:55 +02:00
Andreas Kling c838a2e652 Shell: Add "umask" builtin for reading/writing the shell's umask. 2019-05-10 17:39:30 +02:00
Andreas Kling 67108f872f Shell: Make ^W and ^U work when cursor is not at the end of the line. 2019-05-07 05:29:07 +02:00
Andreas Kling b04f08ba48 Shell: Support home/end keys for line editing. 2019-05-07 05:03:21 +02:00
Andreas Kling d53941a466 Shell: Support basic line editing with left/right arrow keys. 2019-05-07 04:17:05 +02:00
Andreas Kling b860da3ea5 Shell: Ignore tab key for now. 2019-05-07 02:55:56 +02:00
Andreas Kling ad1c3c748f Shell: Allow browsing history with up/down arrow keys. 2019-05-07 02:50:15 +02:00
Andreas Kling 16a5a76445 Shell: Add "history" command that shows command history. 2019-05-07 01:43:21 +02:00
Andreas Kling ba7364b43b Shell: Move line editing to a separate class.
To be clear, there isn't really any line editing yet. But there is
going to be, so let's have it in its own class.
2019-05-07 01:39:41 +02:00
Andreas Kling fe73543d41 Shell: Move the Shell to a separate directory and let's call it "Shell" :^) 2019-05-07 01:12:08 +02:00