-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathman_1_simple_shell
211 lines (169 loc) · 3.52 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
.TH man_1_simple_shell "18 August 2020" " " "Simple Shell Project"
.SH NAME
.B SSP
-
.B Simple Shell Project
.SH SYNOPSIS
.B ./hsh
[command] [options]
The Simple Shell project is a simple UNIX command interpreter.
.SH DESCRIPTION
This manual page explains the work flow and implementation cases, this program
will execute directly any other
software that you want to execute in your system if it can find it directly, or
in your PATH environment variable.
Each input receive in interactive mode will increase the line counter, if a
command can not be found or execute it will return the line counter, and the
respective message inmediatly.
.B Overview
This simple shell is a simplification of a command interpreter, similar to
.B bash.
.TP
Command [option]... ls -la
.SH SHELL BUILT-IN COMMANDS
.SS env
Print the environment variables to STDOUT
.SS exit
Exit the shell.
.SH COMMAND EXECUTION
After a command is read by the interpreter, it will be split into tokens.
Depending on input, the following actions will take place
.PP
If the command is a builtin, the Shell will search the PATH variable
.SH OPTIONS
Simple Shell
operates in both
.I interactive
and
.I non-interactive
mode. The user may initiate
.B simple shell
and begin working or initate
.B simple shell
using commands meant to be run by the program.
.SH ARGUMENTS
The first argument, argument 0 is understood to be the command to be run by
.B simple shell
and arguments following as modifier or options.
.B Return value
The return value of a simple command is its exit status. returns various values depending on the success of the program execution or if an error occurred.
for the directory containing the command.
.PP
If the search is successful, the shell executes the command
.SH ARGUMENTS
The first argument, argument 0 is understood to be the command to be run by
.B simple shell
and arguments following as modifier or options.
.B Return value
The return value of a simple command is its exit status. returns various values depending on the success of the program execution or if an error occurred.
.B Example
.PP
$./hsh
$ touch hello.txt
$ ls
.RS 3
firts.txt
.TB
hello.txt
.TB
second.txt
.RE
$ |
.RS +4
[$ ./hsh
.RE
.RS +4
[$ /bin/ls
.RE
.RS +4
hsh firts.txt hello.txt second.txt
.RE
.RS +4
$
.RE
.RS +4
[$ exit
.RE
.RS +4
$
.RE
.B Run pwd command:
.RS +4
[$ pwd
.RE
.RS +4
/home/vagrant/simple_shell
.RE
.RE
.B Run exit command:
.RS +4
[$ exit
.RE
.RS +4
vagrant@vagrant-ubuntu-trusty-64:~/simple_shell$
.RE
.B Non-interactive mode:
.RS +4
$ echo "/bin/ls" | ./hsh
.RE
.RS +4
firts.txt hello.txt second.txt test_ls_2
.RE
.RS +4
$
.RE
.RS +4
$ cat test_ls_2
.RE
.RS +4
/bin/ls
.RE
.RS +4
/bin/ls
.RE
.RS +4
$
.RE
.RS +4
$ cat test_ls_2 | ./hsh
.RE
.RS +4
hsh main.c shell.c test_ls_2
.RE
.RS +4
hsh main.c shell.c test_ls_2
.RE
.RS +4
$
.PP
.SH RESERVED WORDS
.B exit:
quits the program, exit the shell.
.B env:
displays a list of environment variables
.SH RESERVED KEY-WORDS
.B ctrl + D:
quits the program, exit the shell, similar to command exit.
.B ctrl + C:
ends the process that is running, useful to regain control of the system.
.SH SEE ALSO
.I sh(1)
,
.I bash(1)
.SH BUGS
.SH ENVIRONMENT
When a program is invoked, it is given an array of strings
called the environment.
.SH PROMPT
The shell will display the prompt through the PS1,
ready to take the next command.
.SHS SEE ALSO
bash(1), csh(1), ksh(1), printf(1), login(1), echo(1), getopt(1), test(1)
.TP
Command [option]... ls -la
.SH OPTIONS
.SH BUGS
No known bugs.
.SH AUTHORS
ANDRES BARRERA
GUSTAVO TOVAR