-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathman_1_simple_shell
More file actions
executable file
·119 lines (80 loc) · 3.29 KB
/
man_1_simple_shell
File metadata and controls
executable file
·119 lines (80 loc) · 3.29 KB
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
.TH SIMPLE_SHELL 1 "April 16, 2021" "Holberton School" "General Commands Manual"
.SH NAME
Based in bash - GNU Bourne-Again Shell
simple_shell - command language interpreter that reads from standard input or file
.SH SYNOPSIS
./simple_shell
./simple_shell [file]
[command] | ./simple_shell
gcc -Wall -Werror -Wextra -pedantic *.c -o simple_shell
.SH DESCRIPTION
simple_shell is a command language interpreter that executes commands read from the standard input or from a file.
.TP
.B builtins
.TP
.BR env
list all environment variables
.TP
.BR setenv " " [name] " " [value]
sets the "name" environment variable with to value "value" or updates it if it already exists
.TP
.BR unsetenv " " [name]
deletes the "name" environment variable from the enviroment variables
.TP
.BR cd " " [dir_path]
changes the current working directory to "dir_path"
.TP
.BR alias " " [name=[value] ...]
lists or sets command aliases
.TP
.BR help " " [builtin_name]
displays the help for a builtin command
.TP
.BR history
displays the history commands used by the user in the current sesion
.TP
\fB Return (Exit Value) \fR
Upon termination of the simple shell program, an exit value will be set according to the status of the last command
executed. If the command ran succesfuly, the exit value will be zero (0).
.TP
\fBFORMAT OF COMMAND INPUT\fR
The simple shell can work in two different modes, \fIinteractive\fR and \fInon-interactive\fR. In both modes, commands can be written with their absolute path or simply their executable name if they exist in one of the folders defined by PATH.
Example:
\fB/bin/ls\fR is the same as \fBls\fR (ls exists in one of the PATH folders)
.IP \fB-Interactive Mode:\fR
In this condition, the shell will display a prompt ($) that will indicate that the user can provide commands by writing them
with a keyboard. In order to execute the commands the user will need to press the enter key (new line).
Each time a command is executed, the prompt will reappear and wait for a new user input.
Example:
\fBvagrant@vagrant-ubuntu-trusty-64:~/simple_shell$\fR ./hsh
$ ls
file1 file2 dira dirb
$
In order to exit the simple shell, the user must write "exit" command and press enter or press the combination keys CTRL + D, as the CTRL + C signal is reserved only for internal script termination and it does not exit the shell.
.IP \fB-Non-interactive Mode:\fR
In this condition, the shell will run commands provided through a pipe at the moment of execution, and will not display a prompt
($) or wait for new user input:
Example:
\fBvagrant@vagrant-ubuntu-trusty-64:~/simple_shell$\fR echo "ls" | ./hsh
file1 file2 file3 file4
\fBvagrant@vagrant-ubuntu-trusty-64:~/simple_shell$\fR
.SH EXAMPLES
.B Interactive
vagrant@vagrant-ubuntu-trusty-64:~/simple_shell$ ./simple_shell
$ ls
file0 file1 file2
$ echo 123
123
$ echo $?
0
$ exit
vagrant@vagrant-ubuntu-trusty-64:~/simple_shell$
.B Non Interactive
vagrant@vagrant-ubuntu-trusty-64:~/simple_shell$ echo "pwd" | ./simple_shell
/home/vagrant/simple_shell
vagrant@vagrant-ubuntu-trusty-64:~/simple_shell$ echo "ls" | ./simple_shell
file0 file1 file2
--
.SH AUTHORS
Katherine Soto <kateincoding@gmail.com>
Renato Leon <2829@holbertonschool.com>