Project #1 FAQ
Can your username or hostname change during your shell execution?
Yes, therefore, you should check the username and hostname each time before printing the command-line prompt. As an example, a user may call "su" to become another user.
Do we have to use git?
No, git is just one of several optional collaboration tools you can use when working on a project with a team. You are not equired to use any of them (although using git or some other version control is recommended).If you want to use git, a good way of setting it up is for one of the team to setup a obscure directory name that has execute access only and place the git repository in here (with full read/write access). This prevents others from easily seeing your code (they'd need the name of the directory) while at the same time allowing the group the flexibility to comit changes from anywhere.
Do environment variables have to be capitalized?
No. However, you should be aware that they are case sensitive (e.g., HOME != HoME).
Can I use strtok(), getopt(), lex, ...?
I have no problem with you using strtok as it doesn't completely trivalize parsing. However, I will not offer any advice on how to use it as I prefer you to use the techniques I went over in class.As for things like getopt and lex, they make parsing too easy and can not be used. They would be fine if the focus was on something else, but half of the assignment involves being able to correctly parse input. As such, you can not use them.
For other parsing tools not listed, make sure to ask me. If I see something is trivializing the parsing I will take points off.
Parsing the path???
I've gotten a lot of questions concerning this. This is largely my fault of being vague and trying to generalize. You basically have 2 general cases, 5 total cases you need to deal with:
- Built-in commands: you do not do pathname resolution on the command name
- cd: you do standard pathname resolution on the arguement passed in
- etime, limits: you do pathname resolution only on the command arguement and not the rest
- exit, echo: you do not do pathname resolution on the arguments
- External commands: you do not do pathname resolution on the arguements
- Command contains a '/': do standard pathname resolution on the command name
- Command does not contain a '/': do $PATH pathname resolution on the command name
Can I use global variables?
I have no problem with you using global variables, just make sure that you document what they do. In some cases global variables can actually improve the design (you have less code passing things around). I typically abstain from using them if for no other reason than it is easier to show dependencies with return values and arguments (an example is slide 8 of parsing).If you do use global variables, the two that make the most sense are one for the line read in and one for the parsed line (the actual command). The first can be a global variable with no problems, but the second requires some special considerations. First, you need to have a way of determining the logical size of the array. Second, execv() requires the array be NULL terminated which you can not do with a static array. Third, you don't know ahead of time how many items I'm going to test with. It is still feasible to use this as a global variable, just make sure to address those potential issues and state any assumptions you make