Make 1990/tbr alt version that uses fgets not gets
This is so that the warning about gets() is not interspersed with the
initial output of the program (see below). I do want to note that if one
sends EOF it will segfault so to exit one should do ctrl-c (for
instance) (exit never worked). I will look at fixing that fault later on
to match the original code but this is good for now. When fixed (low
priority though) I will consider making the gets() version the alt but
probably not (I guess time will tell).
As for the interspersed output it looks like:
$ warning: this program uses gets(), which is unsafe.
# cursor is here
At the cursor I can either hit enter to get another prompt or I can
input a command but this is not immediately obvious.
Updated .gitignore to have tbr.alt.
This commit is contained in:
1 parent
e6d578660b
commit
6a6807e587
4 files changed
+45
-4
No files matched your search
+18
-1
@@ -22,11 +22,27 @@ modern computers; `exit(3)` returns void but the function was used in a binary
|
||||
expression so this would not even compile. Thank you Cody for your assistance!
|
||||
|
||||
|
||||
## Alternative code:
|
||||
|
||||
Cody also made a version that uses `fgets()` instead of `gets()` so one would
|
||||
not get a warning that was interspersed with the output of the initial prompt
|
||||
when running the program, to make it both safer and to have a better look. Thank
|
||||
you Cody!
|
||||
|
||||
To build try:
|
||||
|
||||
make alt
|
||||
|
||||
NOTE: it will segfault if you send EOF; to quit send an interrupt like ctrl-c.
|
||||
Cody will look at this later.
|
||||
|
||||
## To run:
|
||||
|
||||
./tbr
|
||||
# enter some shell commands
|
||||
|
||||
NOTE: globs do not work with this entry. Why?
|
||||
|
||||
## Try:
|
||||
|
||||
./tbr
|
||||
@@ -37,6 +53,7 @@ expression so this would not even compile. Thank you Cody for your assistance!
|
||||
vi tbr.c
|
||||
# then figure out how to exit vi :-)
|
||||
|
||||
What happens if you try using `cd -` to return to previous directory?
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
@@ -64,7 +81,7 @@ of the program which we include below:
|
||||
|
||||
|
||||
|
||||
## Author's comments
|
||||
## Author's comments:
|
||||
|
||||
Rot13:
|
||||
|
||||
|
||||
Reference in new issue
Block a user