PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] Local vs Absolute Paths for sh
Date: Thursday, 22 Oct 2020, 20:43:39


    > Message Posted By: Unknown
    >
    > The staff solution seems to print absolute paths for $0, while my program
    > prints the local path used to run the executable. I wrote my program in
    > Python and used the sys.argv list to access arguments. The behavior is
    > shown below.
    >
    > $ cd /c/cs323/Hwk3
    > $ ./mcBash
    > (1)$ $0
    > >> /home/classes/cs323/Hwk3/mcBash
    > (2)$ ^C
    > $ cd ~/cs323/hwk3
    > $ ./mcBash
    > (1)$ $0
    > >> ./mcBash
    > (2)$ ^C
    > $

Always expanding $0 to /home/classes/cs323/Hwk3/mcBash
independent of the name under which Hwk3/mcBash is run
is an artifact of the scheme used to let you run the
program without being able to see the source code.

Thus the output from your program is correct.

--Stan-
PREV INDEX NEXT