mikeizbicki / ucr-cs100

open source software construction course
Other
486 stars 407 forks source link

HW3 grade incorrect #1119

Closed Laviness closed 9 years ago

Laviness commented 9 years ago

grade file: [0/10] Execute a program using an absolute path.

test file: [rshell]Elvis@Lius-MacBook-Air.local:~/Documents/UCR/CS-100/rshell/bin$ ./ls ls rshell

1) I misunderstand a concept in last issue, now I realized ./ls is a absolute path, and I had added a empty PATH in $PATH when I run my shell to make sure all path works, it's on the line 127 in my src code.

link here: https://github.com/Laviness/rshell/blob/master/src/rshell.cpp @benavidz

ghost commented 9 years ago

I'm not sure what you're trying to tell me with point 1 there. Perhaps you could rephrase it?

To clarify, ./ls is not an absolute path, it is a relative path. It can be read as "the file named ls residing in the current directory". That reference to the current directory is what makes it relative, and not absolute. Absolute paths always begin from the root of the file system tree.

Laviness commented 9 years ago

I believe '.' stand for the absolute path for current directory, so ./ls stand for '/Users/Elvis/Documents/UCR/CS-100/rshell/bin/ls' in my laptop. In my opinion they are same. And both paths works although I should have done both. Also from the line 127 you can see the './ls' and '/Users/Elvis/Documents/UCR/CS-100/rshell/bin/ls' are both used the empty path in the front.

ghost commented 9 years ago

Your understanding of '.' is correct, but your understanding of relative vs. absolute paths is not. If you had issued the command './ls' from anywhere other than the directory in which the ls executable is located, it would not have run. On the other hand, no matter what your current working directory is, the command "/Users/Elvis/Documents/UCR/CS-100/rshell/bin/ls" will always work.

I'm unsure what you mean when you say:

Also from the line 127 you can see the './ls' and '/Users/Elvis/Documents/UCR/CS-100/rshell/bin/ls' are both used the empty path in the front.

Laviness commented 9 years ago

I understand what you mean. Could I show the right understanding for absolute path with executing the shell in the office hour too since actually my rshell works well but I thought incorrect? The line 127 shows I add a empty PATH to $PATH so every argument I passed into will finally reach trying run itself, if no other PATH success.

ghost commented 9 years ago

We can discuss this further during office hours.

Laviness commented 9 years ago

okay