-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathman_1_simple_shell
More file actions
56 lines (52 loc) · 2.33 KB
/
man_1_simple_shell
File metadata and controls
56 lines (52 loc) · 2.33 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
.TH SIMPLE_SHELL 1 "22 August 2018" "1.0" "Simple Shell man page"
.SH NAME
.B shell
- a simple command interpreter (shell)
.SH SYNOPSIS
.B ./shell
.SH DESCRIPTION
.B shell
is the simple command interpreter that execute commands read from a terminal command line.
.SH INVOCATION
This shell can run in interactive mode. It reads commands from user input on a tty (stands for teletype - the original terminals used a line printer for output and a keyboard for input). It also can run in non-interactive mode that the shell can not ineract with the user. It runs from a script or similar.
.SH Builtin Search
.TP
When locating a command, the shell first check if the command is a builtin command or not by that name. If a builtin command found, the shell calls the corresponding function by that name. After the corresponding function finishes it's job, the shell skips rest of codes and goes to the next iteration of the outer while loop.
.HP
If builtin search fails, one of two things happens:
.IP 1.
If the builtin command is found with illegal argument, the shell writes error message to STDERR_FILENO.
.IP 2.
If builtin command is not found, the shell goes to next section, path search.
.PP
.SH Builtin Command
.B env
- prints the current environment
.PP
.B exit
- exit the shell (terminate the shell process).
.IP
shell can also exit with a specific return value. For example, exit n (where n is a positive number that is less or equal INT_MAX).
.PP
.B cd
- change current working directory
.PP
.B setenv
- set environment variable
.IP
Initilize a new environment variable, or modify an existing one.
.PP
.B unsetenv
- remove a environment variable
.SH Path Search
After check the command is not a builtin, the shell calls the access function to check if the command is able to execute or not. If the command is not able to execute, the shell searches the path by using the PATH variable (a series of entries separated by colons). Each entry consists of a directory name. The shell concatenate the directory name and the command. Then, pass the concatencated string to access function to check if the command with path (concatencated string) is able to execute or not.
.HP
If path is not found, the shell writes error message to STDERR_FILENO.
.SH SEE ALSO
.I sh(1), bash(1)
.SH BUGS
No known bugs.
.SH AUTHOR
Sumin Yu <suminyu@yahoo.com>
.PP
Peter Wu <pete.h.wu@gmail.com>