C-Shell
A simple shell written in C.
|
This header file contains declarations for the internal commands. More...
#include <stdbool.h>
Typedefs | |
typedef bool | option |
Functions | |
int | cd (int nargs, char **args) |
Change the shell working directory. | |
int | echo (int nargs, char **args) |
Write arguments to the standard output. | |
int | history (int nargs, char **args) |
Print the history of commands. | |
int | ls (int nargs, char **args) |
List directory contents. | |
int | pinfo (pid_t pid) |
int | pwd (int nargs, char **args) |
Print the full filename of the current working directory. | |
void | quit_shell_with_status (int status) |
Quit the shell. | |
void | quit_shell () |
Quit the shell with status 0. | |
int | search (int nargs, char **args) |
Search for a given file or folder under the current directory recursively. | |
This header file contains declarations for the internal commands.
typedef bool option |
int cd | ( | int | nargs, |
char ** | args ) |
Change the shell working directory.
If no path is provided, changes the current directory to /
.
int echo | ( | int | nargs, |
char ** | args ) |
Write arguments to the standard output.
Display the ARGs, separated by a single space character and followed by a newline, on the standard output.
Options:
-c
- separate arguments with commas-n
- no newline at the end-l
- format output as a list int history | ( | int | nargs, |
char ** | args ) |
Print the history of commands.
If no option is specified, prints the last 5 commands.
Options:
-c
- clear the history-r
- read the history file and write to the history list-w
- write the history list to the history file int ls | ( | int | nargs, |
char ** | args ) |
List directory contents.
List information about the FILEs (the current directory by default).
Options:
-a
- do not ignore entries starting with .
-l
- use a long listing format int pinfo | ( | pid_t | pid | ) |
Sample output:
Process status codes:
Note: “+” must be added to the status code if the process is in the foreground.
pid | pid of the process, -1 for the parent process, 0 for the current process |
int pwd | ( | int | nargs, |
char ** | args ) |
Print the full filename of the current working directory.
If no option is specified, -P is assumed. Option -L
overrides -P
when both are used together.
Options:
-L
- use PWD from environment-P
- resolves symlinks to get the current working directory. void quit_shell | ( | ) |
Quit the shell with status 0.
void quit_shell_with_status | ( | int | status | ) |
Quit the shell.
Exits the shell with the given status.
status | exit status |
int search | ( | int | nargs, |
char ** | args ) |
Search for a given file or folder under the current directory recursively.
Prints True or False to stdout depending on whether the file or folder exists.