README.md
Welcome to WyShell
Getting Started
To run WyShell, you have two convenient options:
Option 1: Manual Compilation and Run
-
Clone the Repository:
git clone https://github.com/sambuaneesh/wyShell cd wyshell -
Compile the Shell: Compile the WyShell binary using the following command:
make main -
Run WyShell: Run WyShell by executing the compiled binary:
./wysh
Option 2: One-Step Compilation and Run
You can compile and run WyShell in a single command:
make run
Cleaning Up
To clean up the compiled files and binaries, you can use the following command:
make clean
This command will remove the WyShell executable, the pastevents.txt file, and any other compiled binaries, ensuring a tidy project structure.
Table of Contents
- Welcome to WyShell
Basic System Calls
Display Requirement
The shell prompt is displayed in the following format:
<Username@SystemName:~>
<Username>: Current username@: SeparatorSystemName: System's name~: Represents the current home directory
Example:
<JohnDoe@SYS:~>
Input Requirements
- The shell supports
;or&separated lists of commands. - Commands can be separated by random spaces and tabs.
;is used for sequential commands.&runs the preceding command in the background.
Example:
<JohnDoe@SYS:~> command1 ; command2 & command3
Shell Commands
warp [path]
The warp command changes the current directory to the specified path and updates the prompt accordingly. It supports symbols like . (current directory), .. (parent directory), ~ (home directory), and - (previous directory).
Example:
<JohnDoe@SYS:~> warp test
/home/johndoe/test
<JohnDoe@SYS:~/test> warp ~
/home/johndoe
<JohnDoe@SYS:~>
peek [flags] [path/name]
The peek command lists files and directories in the specified directory. It supports -a (show hidden files) and -l (display extra information) flags.
Example:
<JohnDoe@SYS:~> peek test
# Output
<JohnDoe@SYS:~> peek -al test
# Output with extra information
pastevents
The pastevents command displays the 15 most recent command statements based on certain constraints. It is persistent across different shell runs.
Example:
<JohnDoe@SYS:~> pastevents
# Output the 15 most recent commands
<JohnDoe@SYS:~> pastevents execute 1
# Execute the command at position 1
<JohnDoe@SYS:~> pastevents purge
# Clear all pastevents
System Commands
Foreground Process
Foreground processes wait for completion, and their output is displayed in the terminal.
Example:
<JohnDoe@SYS:~> sleep 5
# Executes sleep command in foreground
Background Process
Background processes run asynchronously. Their PIDs are displayed in the terminal.
Example:
<JohnDoe@SYS:~> sleep 10 &
# Executes sleep command in the background
ping <pid> <signal_number>
The ping command is used to send signals to processes. Take the pid of a process and send a signal to it corresponding to the provided signal number. Print error “No such process found” if the process with the given pid does not exist.
Example:
<JohnDoe@SYS:~> ping 221 9
Sent signal 9 to process with pid 221
<JohnDoe@SYS:~> ping 430 41
Sent signal 9 to process with pid 430
Ctrl - C, Ctrl - D, Ctrl - Z
- Ctrl - C: Interrupts any currently running foreground process by sending it the SIGINT signal. It has no effect if no foreground process is currently running.
- Ctrl - D: Logs out of your shell (after killing all processes) while having no effect on the actual terminal.
- Ctrl - Z: Pushes the (if any) running foreground process to the background and changes its state from “Running” to “Stopped”. It has no effect on the shell if no foreground process is running.
proclore [pid]
The proclore command provides information about a process with the given PID.
Example:
<JohnDoe@SYS:~> proclore
# Displays information about the shell
process
<JohnDoe@SYS:~> proclore 301
# Displays information about the process with PID 301
seek [flags] [search] [target_directory]
The seek command searches for a file/directory in the specified target directory. It supports -d (look for directories only) and -f (look for files only) flags.
Example:
<JohnDoe@SYS:~> seek newfolder ./doe
# Output matching files/directories in ./doe
Processes, Files, and Miscellaneous
I/O Redirection
The shell supports input/output redirection using >, >>, and < operators.
Example:
<JohnDoe@SYS:~> echo "Hello world" > newfile.txt
# Redirects output to newfile.txt
<JohnDoe@SYS:~> wc < a.txt
# Reads input from a.txt and performs word count
Pipes
The shell supports piping multiple commands.
Example:
<JohnDoe@SYS:~> echo "Lorem Ipsum" | wc
# Pipes output of echo to wc command
Redirection along with Pipes
The shell supports redirection along with pipes.
Example:
<JohnDoe@SYS:~> cat < a.txt | wc | sed 's/ //g' | cat > b.txt
# Redirects input from a.txt, pipes through wc and sed, and outputs to b.txt
Process Management
The shell supports process management commands fg and bg.
Example:
<JohnDoe@SYS:~> fg 620
# Brings process with PID 620 to foreground
<JohnDoe@SYS:~> bg 620
# Changes process with PID 620 to background
Neonate Command
The neonate command prints the Process-ID of the most recently created process at specified intervals until the 'x' key is pressed.
Example:
<JohnDoe@SYS:
~> neonate -n 4
# Prints PID every 4 seconds until 'x' is pressed
11810
11811
11811
11812
11813 # Key 'x' is pressed, terminating the printing
Networking
iMan [command_name]
The iMan command fetches man pages from http://man.he.net/ using sockets.
Example:
<JohnDoe@SYS:~> iMan sleep
# Fetches and displays the man page for the 'sleep' command