-
Notifications
You must be signed in to change notification settings - Fork 0
/
man_1_simple_shell
executable file
·101 lines (101 loc) · 2.74 KB
/
man_1_simple_shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.TH SIMPLE_SHELL 1 "02 November, 2022" "1.0" "custom man page"
.SH NAME
.B Simple Shell
- command language interpreter
.SH SYNOPSIS
.B Simple Shell
.SH DESCRIPTION
Simple shell is one version of a command language interpreter that executes commands read from the standard input. It's functionality is limited to certain shell builtin functions found in the environmental variable
.I PATH.
It does not yet handle piping, redirection, pattern matching, variable expansions, and more extra functions.
.SS Invocation
An
.I interactive
simple shell can be invoked by typing ./simple_shell. Meanwhile, a
.I non-interactive
simple shell can also be invoked via a pipe (e.g. echo "/bin/ls" | ./simple_shell).
.SS Command Execution
After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.
.sp
If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name that function is invoked. If the name does not match a function, the shell searches for it in the list of shell builtins. If a match is found, that builtin is invoked.
.sp
If the name is neither a shell function nor a builtin, and contains no slashes, the simple shell searches each element of the environmental variable PATH for a directory containing an executable file by that name. If the search is unsuccessful, the simple shell prints an error message "Error: File or description not found."
.SS Sample Functions
.sp
echo
.I [arguments]
prints to standard output the argument(s) given and prints a newline
.sp
ls
.I [[flags]...[arguments]]
lists files in the current directory according to the flags given by user
.sp
pwd
prints working directories
.sp
whereis
.I [command]
prints to standard output which directory the function or shell builtin can be found
.SS Shell Builtin Commands
.sp
cd
changes directory and updates environmental variables OLDPWD and PWD
.sp
env
prints environmental variables
.sp
exit
exits out of simple shell and returns to user's original shell
.sp
setenv
creates non-existing or modifies existing environmental variable within shell session
.sp
unsetenv
removes existing environmental variable within shell session
.SH EXAMPLE
To
.I invoke
simple shell:
.sp
.RS
(your_terminal)$ ./simple_shell
.RE
.RS
.I $
.RE
.sp
Sample Usage:
.sp
.RS
.I $
echo "This is pretty cool!"
.RE
.RS
.I This is pretty cool!
.RE
.RS
.I $
ls -l /tmp
.RE
.RS
.I total 4
.RE
.RS
.I drwx------ 2 vagrant vagrant 4096 Mar 19 20:22 ssh-xTKqci
.RE
.sp
To leave simple shell and return to your terminal:
.sp
.RS
.I $
exit
.RE
.RS
(your_terminal)$
.RE
.SH BUGS
Bugs...
.SH SEE ALSO
.I bash(1), sh(1), ksh(1), csh(1)
.SH AUTHORS
David Oluwafemi and Enoch Ayinde