Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

Why shell scripts have to set PATH

Here is an extreme example showing why all shell scripts should set the PATH variable. Less extreme versions of this happen in real life all the time.

In this hypothetical example, you are a very silly person. Your home directory is /u/csc209h/summer/pub/silly. In there you have created a 'bin' directory containing a command named "cat" which says "meow".

You put this directory in your PATH, of course. Putting this directory in your PATH might even be the system default.

To experience this, in sh type:

PATH=/u/csc209h/summer/pub/silly/bin:/bin:/usr/bin
export PATH
or in tcsh type:
set path = (/u/csc209h/summer/pub/silly/bin /bin /usr/bin)

Type "cat" and see it say "meow".

Now try running some shell scripts which don't set the PATH variable, and some which do.

(If you don't have any examples lying around, try /u/csc209h/summer/pub/silly/script1 and /u/csc209h/summer/pub/silly/script2. Usage: sh script[12] file.)