Schedule
Labs
Assignments
TA office hours
Topic videos
Some course notes
Extra problems
Lecture recordings
A shell script containing the following code is executed:
if x then y else z fi
a) Write the command 'x' (either as a shell script, or in C if you prefer) so that the command 'y' will be executed.
exit 0
C program:
int main() { return(0); }
All sorts of other shell scripts are possible, such as
cat /dev/null
b) Write the command 'x' (either as a shell script, or in C if you prefer) so that the command 'z' will be executed.
exit 1
C program:
int main() { return(1); }
All sorts of other shell scripts are possible, such as
rm / 2>/dev/null
or
false
or
test 3 -eq 4