Skip to content

Commit 3ba73ec

Browse files
committed
Enhanced extra feedback.
1 parent 90cbb2f commit 3ba73ec

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

docs/class-assignments/extra-feedback.txt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Additional notes on the lab assignment based on existing implementations.
22

33
--------------------------------------------------------------------------------
4-
Split the program into (potentially many) .c files. For example one for command
5-
line parsing, another for utility functions, one for execution/pipe handling,
6-
etc. etc.
4+
You may want to split the program into (potentially several) .c files. For
5+
example one for command line parsing, another for utility functions, one for
6+
execution/pipe handling, etc.
77

88
The program becomes better structured with a room for expansion/growth.
99

1010
--------------------------------------------------------------------------------
1111
Do not blindly accept potentially unlimited user input. It probably does not
12-
make sense for command line to be millions of characters long.
12+
make sense for a command line to be millions of characters long.
1313

1414
--------------------------------------------------------------------------------
1515
Check return values of any call that can fail.
1616

1717
Yes, malloc() can fail too.
1818

19-
Reacting on failures needs to be sensitive, though. Exiting the shell
20-
when malloc() fails is safe thing to do. On the other hand, failing to read a
21-
file in interactive mode should not tear down the shell.
19+
Reacting on failures needs to be sensitive, though. Exiting the shell
20+
when malloc() fails is a safe thing to do. On the other hand, failing to read a
21+
file in an interactive mode should not tear down the shell.
2222

2323
--------------------------------------------------------------------------------
2424
The shell should not assume it is being run from another shell.
@@ -41,14 +41,15 @@ if (pipe(pd) == -1) {
4141
Speaking of style, try to refactor as much as possible (while using function
4242
names easily readable by humans - and stick to consistent casing style).
4343

44-
When is function too long ? (so that it can be called "spaghetti code")
45-
If it spans multiple screens of wide screen terminal (let's say 80 lines
46-
printed in the font usually used in your environment for source code) it is
47-
probably time to do some refactoring.
44+
When is function too long? (so that it can be called "spaghetti code") If it
45+
spans multiple screens of a wide screen terminal (let's say 80 lines printed in
46+
the font usually used in your environment for source code) it is probably time
47+
to do some refactoring.
4848

4949
--------------------------------------------------------------------------------
50-
Refuse special characters that you do not implement yet. For example, if you do
51-
not implement pipes (as in the 1st phase), refuse it. It cannot work like this:
50+
Refuse special characters that you do not implement yet, or treat them as normal
51+
characters. For example, if you do not implement pipes (as in the 1st phase),
52+
refuse it. It cannot work like this:
5253

5354
$ date | cat | sort | wc -l
5455
Mon Dec 31 13:06:56 CET 2018
@@ -61,27 +62,29 @@ If you did accept '|' as a normal character, it should have worked like this:
6162
$ echo hello | wc -l
6263
hello | wc -l
6364

64-
And in case of date(1), it should have printed out an error, similar to this:
65+
And in case of date(1) above, it should have printed out an error, similar to
66+
this:
6567

66-
$ date xxx
68+
$ date |
6769
date: illegal time format
6870
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
6971
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
7072

71-
So, do something like the following:
73+
So, you can do something like the following:
7274

7375
$ echo hello | wc -l
7476
(default rule matched) error:1: syntax error near unexpected token '|'
7577

7678
Also, refuse redirections unless you already implemented those. The following
77-
is not correct in the 1st phase:
79+
is not correct in the 1st phase (again, you can treat it as a normal character,
80+
too, until implemented):
7881

7982
$ echo hello > out
8083
hello
8184

8285
--------------------------------------------------------------------------------
83-
Please do implement command line history. In case of readline, it's really just
84-
calling one function, like this, for example:
86+
Please do implement a command line history. In case of readline, it is really
87+
just calling one function, like this, for example:
8588

8689
if ((input = readline(prompt) ...
8790
...

docs/class-assignments/labs-assignment-2020.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ benefit from the answers as well.
3333

3434
C Style
3535
-------
36-
Please choose a good C style, for example http://mff.devnull.cz/cstyle/,
37-
or pick another existing cstyle (e.g. https://man.openbsd.org/style).
38-
Please do not invent your own C style.
36+
Choose a good C style, for example http://mff.devnull.cz/cstyle/, or
37+
pick another existing cstyle (e.g. https://man.openbsd.org/style), and
38+
stick to it. Please do not invent your own C style.
3939

4040
This class is about Unix/Linux programming in C, so we only accept the C
4141
language, not C++.

0 commit comments

Comments
 (0)