Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

3.

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.

Sample solutions:

shell script:
    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.

Sample solutions:

shell script:
    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


[sample midterm from Fall 2012]