-
Notifications
You must be signed in to change notification settings - Fork 0
/
man_1_simple_shell
120 lines (100 loc) · 4.23 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
.TH man 1 "24 Nov 2020" "Version 1.0" "simple_shell man page"
.SH NAME
.B simple_shell - our own simple simple_shell take commans from the standard input and executes them
.SH SYNOPSIS
.PP
[#FAKE SHELL] /.../simple_shell $ [command]
[#FAKE SHELL] /.../simple_shell $ [command][filename]
.SH DESCRIPTION
.PP
.B Simple shell is a command-line interpreter that provides a command line user interface for Unix-like operating systems.
This shell will interpret the command from an interactive and non-interactive mode, executing the command you type in the standard input
with or without arguments and with files.
check if the input is in interactive mode or not, in either case it will initialize the same variables that will be a char double pointer, a line counter and a biult ins checker; if it is interactive mode, it contains a signal if the input is a ctrl C to stop the execution, since there is no signal he enters the loop infito where the first thing is to show the prompt and stays waiting for the user to enter some command
the program reads the command and tokens the line, checks if it is a built-in or not, in case it is it goes where it is and executes it, in case it is not it interprets the line it checks if it is an executable command, if it is false it shows an error message, if it is true, it executes it, releases the memory and finishes.
If the process is non-interactive, after initializing the variables, it will read the user input and touch, check if it is a built-in to go to execute it and if it finds that builtin is 0 it ends, another reason for it to end is that the command is null; once the above interprets, check if it is an executable command in case it is not, it prints it and if it is, it executes it, releases it and ends
.PP
.B Return Value
0 Sucessful
.PP
.B
.SH OPTIONS
.PP LIST Most used commands
.IP ls
list directory contents
.IP /bin/ls
go to the variable enviroment PATH find the file /bin and execute ls
.IP ls_-l
use a long listing format
.IP echo
display a line of text
.IP mv
move (rename) files
.IP Ctrl[C]
End of file
.IP Ctrl[D]
End of a simple shell
.SH buitl-in commands
.IP exit
cause normal process termation
.IP env
run a program in a modified environment
.SH EXAMPLE
.PP
.B interactive mode
`$ ls`
```
AUTHORS aux_strings.c execute.c leak_control.c testing
README.md aux_strings1.c hsh man_1_simple_shell
_getline.c built_ins.c interactive.c non_interactive.c
a.out entry_point.c interpeter.c shell.h
```
`$ ls -l`
```
total 84
-rw-r--r-- 1 luna luna 190 Nov 25 18:55 AUTHORS -rw-r--r-- 1 luna luna 4468 Nov 25 23:20 README.md
-rw-r--r-- 1 luna luna 890 Nov 25 23:23 _getline.c
-rwxr-xr-x 1 luna luna 18496 Nov 25 17:58 a.out
-rw-r--r-- 1 luna luna 2583 Nov 25 19:09 aux_strings.c
-rw-r--r-- 1 luna luna 1839 Nov 25 19:36 aux_strings1.c
-rw-r--r-- 1 luna luna 564 Nov 26 11:27 built_ins.c
-rw-r--r-- 1 luna luna 230 Nov 25 15:12 entry_point.c
-rw-r--r-- 1 luna luna 339 Nov 25 19:42 execute.c
-rwxr-xr-x 1 luna luna 18496 Nov 25 19:10 hsh
-rw-r--r-- 1 luna luna 1406 Nov 25 16:56 interactive.c
-rw-r--r-- 1 luna luna 2674 Nov 25 10:55 interpeter.c
-rw-r--r-- 1 luna luna 1910 Nov 25 19:46 leak_control.c
-rw-r--r-- 1 luna luna 582 Nov 25 16:57 man_1_simple_shell
-rw-r--r-- 1 luna luna 382 Nov 26 11:27 non_interactive.c
-rw-r--r-- 1 luna luna 1327 Nov 25 19:09 shell.h
drwxr-xr-x 1 luna luna 4096 Nov 25 10:55 testing
```
`$ /bin/ls `
```
AUTHORS _getline.c aux_strings.c built_ins.c execute.c interactive.c leak_control.c non_interactive.c testing
README.md a.out aux_strings1.c entry_point.c hsh interpeter.c man_1_simple_shell shell.h
```
`$ /bin/ls /bin/ls /bin/ls`
```
/bin/ls /bin/ls
```
`$ echo simple example`
```
simple example
```
`$ inexistent_command`
```
./hsh: 1: inexistent_command: not found
```
non interactive mode :
$ echo ls | ./a.out
AUTHORS _getline.c aux_strings.c built_ins.c execute.c interactive.c leak_control.c non_interactive.c testing
README.md a.out aux_strings1.c entry_point.c hsh interpeter.c man_1_simple_shell shell.h
$ echo "/bin/ls /bin/ls /bin/ls"
/bin/ls /bin/ls /bin/ls
.SH SEE ALSO
.SH BUGS
No know bugs.
.SH AUTHORS
Giraluna Gomez @Giraluna1
Luis Patiño @LuisPatino92