-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTODO
119 lines (83 loc) · 4.85 KB
/
TODO
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
B1. (2 pts) Abstracted command calling scheme
You are to make adding new commands simple.
For example, you can create a single directory where all the executable Haskell command files are kept.
You should dynamically call them when a user tries to execute a command in hash.
Alternatively, create a (Name, Command) dictionary which can be easily modified.
Extra points may be given for especially creative or elegant solutions.
B2. (6 pts) Conditional branching – if-then-else(-fi)
The conditional branching has to support at least a single if and a single if-else pair.
You do not have to implement both numeric (>, <, . . . ) and string (-eq, -gt, ...) comparison.
You may pick only one. Furthermore, you do not have to support nested if-then-else statements.
Example (your syntax may be different):
if $a > 9000 then
echo "It’s over 9000!";
else
echo "It’s too low.";
fi
B3. (3 pts) Basic file manipulation commands mv (move), cp (copy), rm (remove), create.
They have to support both absolute and relative paths.
mv src target ⇒ Moves a source file to the target file
mv src ... directory ⇒ Moves one or more files to a target directory
cp src target ⇒ Copies a source file to the target file
cp src ... directory ⇒ Copies one or more files to a target directory
rm file ... ⇒ Removes one or more files (not directories)
create file ... ⇒ Creates one or more empty files
B4. (3 pts) Basic directory manipulation commands mv (move), cpdir (copy), mkdir (make directory), rmdir (remove directory).
They have to support both absolute and relative paths.
mv dir ... dir ⇒ Moves one or more directories to a target directory
mv dir new name ⇒ Renames the directory to new name
cpdir dir ... directory ⇒ Copies one or more directories to a target directory
mkdir dir ... ⇒ Creates a new empty directory
rmdir dir ... ⇒ Removes an empty directory
B5. (3 pts) Basic file system navigation commands ls (list directory contents), pwd (print working/current directory), cd (change directory).
These commands have to support both absolute and relative paths.
ls [dir] ⇒ Lists the contents of the given directory, or the current one if no argument is given.
pwd ⇒ Prints the current directory (working directory)
cd [dir] ⇒ Changes the working directory to a given one, or the user’s home directory if no argument is given.
B6. (5 pts) Stream redirection.
hash commands have to read from the stdin and write to the stdout by default.
The user has to be able to redirect input and output from and to files.
Support the > (redirect output to file), < (redirect input from file) and >> (appends output to file) operators.
echo "Overwriting" > file.txt
echo "Appending" >> file.txt
foo < input.txt
B7. (2 pts) Basic comment syntax
For example, lines beginning with # or whitespace followed by # are comments and are ignored by hash.
You do not have to support comments appearing after meaningful content.
# This is a comment
This is a command > file.txt # Doesn’t have to be a comment
# Another comment
B8. (3 pts) Variables, marked in a way to make them different from commands and string
literals – for example prefix them with $.
a=10
echo $a
# Prints 10
B9. (2 pts) A basic cat command that dumps the contents of a variable number of files (one or more) to the screen (or a file, if redirected).
B10.
(3 pts) A basic echo command that repeats user input to the screen, replacing any
instances of variables with their values.
a=67
echo "$a bottles of beer on the wall"
# Prints "67 bottles of beer on the wall"
A1. (4 pts) A basic grep command that matches lines containing a given string literal.
It should support the -v, -i, -o, -n and -c flags.
A2. (5 pts) Command piping. Using some special operator (for example |) hash should
be capable of chaining commands so that the output of one command is made input
into another.
A3. (3 pts) A basic chmod command for editing file and directory permissions. It should
take a rwx permission mask and a list of files and adjust their permissions. (Hint:
System.Posix.Files)
A4. (5 pts) Glob expansion of names in the shell.
A5. (8 pts) Some form of loops – while, for or foreach. Multiple loop implementations
are not scored separately.
A6. (8 pts) Forking processes. Some command or special operator should be capable of
starting another command in a new process. You also have to implement stopping
or killing the new process in some way.
A7. (3 pts) Implement a hexdump command that, given a file, prints out its byte contents
as hexadecimal numbers.
A8. (2 pts) Support .hashrc files. These files contain hash syntax that should be exe-
cuted before running a hash script or starting an interactive session. They should
be no matter in which directory hash is started – for example, always look in the
user’s home directory.
A9. (3 pts) Implement a ping command. It should perform the same task as a vanilla
(flagless) version of ping.