/
README
87 lines (54 loc) · 2.56 KB
/
README
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
# README for Hank Shell (Hsh)
# Hsh is a simplified version of BASH.
[How to use hsh]:
(1) First you need to install gnu readline library:
$ sudo apt-get install libreadline6 libreadline6-dev
(2) Second you need to compile and install hsh:
Run 'make' in the 'src/' sub-directory ==> $ make
[Hsh Features]:
(1) Below lists all (9) the builtin commands implemented in Hank Shell:
cd : change current working directory
dirs : list pushed directories on the directory stack
exit : terminate exeucution of hsh
echo : echo strings that follow this command
history : show commands history
pwd : print current working directory
pushd : push directory onto a directory stack
popd : pop directory from directory stack
path : list command search paths from command paths list and add/remove path(s) from that list
(2) Builtin commands details:
cd [dir] : change directory to dir. If dir is omitted, change directory to home directory.
dirs : print directories pushed on directory stack; seperated by spaces.
exit : exiting hsh program.
echo [s] : print whatever texts followed echo commands.
history [+n] : show n commands stored in command history list; if 'n' or '+n' is omitted,
hsh will list all the commands in command history.
pwd : print current working directory
pushd [dir] : same as 'cd', but push current working directory onto directory stack
while doing 'cd'. directory stack is a hsh internal data structure.
popd [-n] : opposite of 'pushd'. option '-n' specify how many entries from stack you want to pop.
path [+|-] [dir] : add or remove dir from directory path list. if both '+|-' and 'dir' arguments
omitted, hsh will print all the directories in the list. the list is a hsh
internal data structure.
(3) IO redirection:
Commands like 'cat < main.c > tmp' can be interpreted by Hsh!
(4) Pipeline with IO redirection:
Hsh can read pipes ('|')!
Commands such as -
$ pwd | grep main | cut -b 1-10
$ a | b | c | d | e
$ cat < main.c | wc
$ tr 'A-Z' 'a-z' < main.c | tr -cs 'a-z' '\n' | sort | uniq | comm -23 - /usr/share/dict/words > tmp 2> err.txt
can be executed beautifully without any problems. Also notice that pipes in Hsh can pipe system utilities as well
as builtin commands!
(5) Environmental variables:
Two environmental variables are implemented, namely, HOME and PWD. Therefore,
$ echo $HOME
$ echo $PWD
can also be interpreted correctly.
(6) 'Globbing' for Hsh:
Yes! Hsh can do globbing! The followings
$ ls *.c
$ ls test[1-3].c
$ ls hsh.* | wc
are all doing what you are expecting them to do!