mikeizbicki / ucr-cs100

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

running ./a.out or bin/ls in rshell #93

Closed willccoates closed 10 years ago

willccoates commented 10 years ago

i am still confused about this, i get the concept but implementing it is where i get lost. are we supposed to open our current directory, check each item in directory to see if it matches the input and then run exec on the path if it does match?

mikeizbicki commented 10 years ago

No, you should just run execv on whatever the user types in. So if the user types in: asdfgh, then you should call execv("asdfgh", ... ). That way, if the user types in bin/ls, it will first try to run the program in bin/ls before trying all the combinations in the PATH variable.

willccoates commented 10 years ago

so i should parse the user input, pass to execv, if fails then work with paths?

mikeizbicki commented 10 years ago

exactly