# Spec 1 Q1. Can we get a bit more clarity on how the pathname should look like Say I am in home/desktop/3rd_sem/osn/mp1 and I am executing my code, how should the output look like?? [SJ] The directory from where you are executing your shell command is the home directory for your shell. Let's suppose you started your shell from osn directory in your example . So shell home directory is till osn. Then if you execute hop mp1 your path shd be ~/mp1 Q2. Can we use fgets() [SJ] Yes Q3. What should the program do if the directory it is currently in, is deleted by another program, i.e. should it check for that and move to some other directory in case this happens? [DP] You don't need to handle this. Q4. Are we free to use commands other than mentioned . Like , can we use gethostname()? [KM] Yes. The commands mentioned are by no means exhaustive, they're simply there to aid you in your search. You are free to use any command you see fit as long as it hasn't been disallowed by the requirements of that respective specification, isn't disallowed by the [guidelines](https://karthikv1392.github.io/cs3301_osn/mini-projects/mp1#guidelines) and isn't from a third-party library. Q5. To go to parent directory we should execute cd .. right ? does it mean we should implement cd functionalities? [KM] Yes, this is precisely what Spec-3 is (you'll be implementing `hop` which essentially does what `cd` does). **Please go through the entire specifications document.** Q6. Are we allowed to use strcspn? [DP] Yeah, unless explicity prohibited you are free to use in-built helper methods. Q7. Are we expected to handle cases like "echo "Hello" > file1.txt > file2.txt > file3.txt" ? [KM] No, you do not need to handle cases with multiple I/Os. At best, you can expect to be tested on a case like `echo "Hello" < a.txt > b.txt`. Q8. Are we expected to handle cases like "command < input.txt > output.txt 2> error.log" ? [KM] If you are handling "2>" (error redirection), then yes. However, we do not expect you to handle cases with error redirection. Supporting ">", ">>", "<" is enough. # Spec 2 Q1. It says that the errenous commands must be printed out. Are the valid commands considered to be all the shell commands possilble in Linux or can we just validate with a subset of the commands that are valid in the shell? [IG] All the commands provided in specifications + those commands that can be executed successfully with execvp() are considered valid. Q2. Can ; and & come in the same line? If so, how to determine the order of which processes will be in the foreground and which ones will be the in the background? [IG] They can come in the same line. For example, your program should be able to handle commands like: `<JohnDoe@SYS:~> echo "Hello World" ; sleep 7 &` Output in this case would be Hello World (foreground process) followed by the PID of sleep 7 command that will run in background. Q3.Can we Use execvp ? [DP] You don't need execvp here at all. You might be confused about the given examples implementing 'sleep' but that is just an example to show how the commands separated by `&` and `;` need to be executed separately. Handling system commands will be implemented in Specification 6. For now you just need to process what commands have to be executed. Q4. Will we have only one & and one ; or multiple & and ; Also can we use execl?? [SJ] You can have multiple ; and & in a command. For using execl refer to Q3 Answer. Q5. Correct me if I'm wrong so for this part we don't need to execute anything we just need to tokenize the input command such that the ;,& separated commands are valid?? [SJ] You will need to handle these commands in Specification 6 . For Specification 2 tokenising is fine . Q6. How should our shell handle cases when multiple lines are entered as a single command? Different shells handle this differently. For example if ``` line 1 line 2 ``` is the input, some shells may take `line 2` as input to `line 1` if needed, while others don't (and they execute `line 2` after `line 1`). Can we ignore such cases? [SJ] Yes you can ignore such cases . Further if you are doing then either you have given `\n` as input in `line 1` which would execute `line 1` and then `line 2` . Q7. Will space be given after `;` , `&` in input? [SJ] There could be arbitary number of spaces in input. Handle every case. Q8. What should be considered as the maximum input length? [KM] Up to you to decide. Anything greater than ~~512~~ 4096 characters should be good enough. Just mention it in as an assumption in your README.md. *Edit: You could go a step further, and simply define this as a macro in your header file so that you can change it as and when required :)* Q9. Can & operation be combined with our custom defined functions For example can we get log & hop dir1 [DP] You aren't expected to implement background functionality for your custom commands. So `log & hop dir1` isn't something we are looking for. You can have `sleep 5 & hop dir1` though since here a system command goes into background. Q10. Can there be more than one spaces between commands eg hop Dir1 [DP] Refer Q7. You can have an arbitrary amount of whitespaces in the input which have to be handled. Also <b>Refrain from asking redundant doubts.</b> Q11. Can the ; or & imply anything other than their typical meaning? For ex: echo "hello & World ; " will mess-up the implementation if strtok is used. [DP] Refer Point 16 of the Guidelines in the mini-project document. Special symbols would always correspond to their special meaning. <b>It's important to go through the doc carefully before asking doubts.</b> Q12. Do we need to handle multiple background processes as well? (example-command1 & command2 & command3)? [KM] Yes. Q13. If given a command such as `echo 123;123`, we have to print 123 and then print error that 123 is a wrong command, please also confirm for any character `; > >> < ~` ? [AA] You can assume that if these characters occur, it is only for their special functions. So yes, print an error for `;`. In general, you follow how bash deals with it (for input without quotes). Q14. Running an interactive program like nano , vim in the background causes both the shell and the program to not work as intended. Do we need to handle this? If so then do we redirect the stdin and stdout of the programs to something else? [KM] You are expected to make it fully functional. It is up to you to determine how you'll achieve this. *Hint: Look into process group IDs and what they mean for the process itself, and how these group IDs relate to the terminal as well :)* # Spec 3 Q1. When we get a command like 'hop ~' are we supposed to jump to the directory where the c shell code is present or the home directory of the system? [SJ] C Shell code. Q2. Can it be safely assumed that the absolute paths to be handled will be starting with '/' (the root) or something like '/home'? [KM] Yes, since by definition, absolute paths must start from the root directory of the filesystem. Q3. Do we need to check if the required directory to which we have to hop in the specified relative / absolute path exists? [KM] Yes. As a general guideline, you are expected to perform error handling for any and all such cases, for all the specs. Refer to point 5 of "General Guidelines" in the mini project document. Q4. Can we use `chdir()` ? [AA] Yes, you may. Q5. Are we allowed to use `S_ISDIR` function to check if specified directory exists or not? [AA] Yes. Q.6 Is it safe to assume that the absolute path would not be the directory in which the shell is present? If not then will it be fine if we still show the new directory with relative path ? [SJ] If you go to a path which is outside of your path invoked from shell(Code) you have to show absolute path , whereas currently if you are in a subdirectory of shell you need to go in relative path. The directory from which your shell(Code) is invoked is your home directory . Q7. Can we restrict the further change to previous directory when we are already at the home directory where the code is actually present? Or do we need to allow even those changes? [SJ] Yes you need to. Q8. If we encounter a command like hop dir1 dir2 and if dir2 fails do we still execute the hop dir1 or not? [SJ] Execute dir1 and give error for dir2. Q9. If the input is `hop .. test` and hop .. works and test does not work what do we do in that situation? Do we execute hop .. and stay at the new directory or go back to the original directory before the execution of command? [SJ] Same ans as Q8. Q10. If I am in the directory from which shell is invoked and I do hop .. it should stay in the same directory right?? [SJ] It should go outside the directory and show absolute path. Q11. Shouldn't the command `hop .. test` be an invalid command (doesn't matter whether the test directory exist or not)? In place of it we can use `hop ../test` or `hop ..; test` [DP] No, `hop .. test` is valid. You should first hop to the parent directory and then hop to test if it exists. `hop ../test` achieves the same purpose but both are valid. Q12. ![image](https://hackmd.io/_uploads/B1h89zR5R.png) what would be the previous directory in this `home/johndoe/test` or `home/johndoe/test/assignment` ? (if not understood what would be the directory if after this operation we perform hop - ?) [DP] `home/johndoe/test` in this case. Q13. What does `hop .` do? Just print the name of the current directory, or change the directory to parent directory, or is this work done by `hop ..` ? [KM] **(UPDATED:)** `.` is the relative path of the current directory that you're in (current working directory). Since `hop` is supposed to print the ~~relative path~~ absolute path of the current directory from the home directory **of the shell**, `hop .` should simply print the ~~relative path~~ absolute path of the current directory from the home directory of the shell. *Note that if you implement everything in a generalised manner, you shouldn't have to handle this scenario separately.* Q14. What does `hop -` do? [KM] This scenario has been depicted in the example under this specification. **Please go through the examples before asking a question.** `-` refers to the previous working directory. So, `hop -` should take you back to the previous working directory. Note that if no directory changes have taken place yet, then as there is no previous working directory, you can choose to display a warning message to the user (can be anything, but usually it is "OLDPWD not set"), and simply stay in the current directory. Q15. (continuation to Q14) then what is difference between - and .. [KM] The previous working directory need not necessarily be the parent directory. Q16. Are we supposed to handle any other test cases other than the the ones mentioned ?(like are there any other testcases similar to hop ~/project) [KM] The testcases mentioned in the specifications document are **NOT** exhaustive. We will test your shell on our own internal set of testcases. You are expected to think of all the possible cases, and implement accordingly. Q17. Can we use 'getpwuid' function? [SJ] Yes Q18. "Specification 3 : hop [5] ‘hop’ command changes the directory that the shell is currently in. It should also print the full path of working directory after changing. The directory path/name can be provided as argument to this command. " While printing the full path should it again be with respect to the currently working directory or should the entire adress be given? ( not talking about the recurring terminal line) [DP] Refer Q6. It essentially depends on where you are w.r.t your root directory ~~(i.e, the directory where your shell resides).~~ [KM] Root directory in this case refers to the root directory of the file system. Q19. In Q13 it was answered that hop . should print the relative path,so if I'm in the home directory of the shell code should it print ~ and if I'm in a directory inside the home directory of the shell code for example xyz and when hop . should I print ~/xyz or the absolute path? [IG] For home directory of shell, print its absolute path and for some subdirectory xyz, print <absolute path>/xyz. [KM] Q13 has been corrected now, you are expected to print the absolute path always. Q20. If no argument is given should we hop to home directory of the shell code and print ~ or should we hop to the home directory and print the absolute path? [SJ] Home directory of the shell code and print absolute path of the home directory of the shell. Q21. In hop lets say we are executing some commands but after which some invalid directory was given to hop to so we will stop the execution right there? But will change the directory for the previous command (as per answer of Q8 (spec 3))? Am I thinking correct? In this case should we log the command given or not(as for invalid commands we are not allowed to put them)? [SJ] Yes you are thinking correctly. For logging part refer to Ans1 of Spec5 Q22. Whenever we are given multiple commands so after executing one we will print the directory and then will execute and then print and so on or should we print the final directory which we get after execution? [SJ] You have to print all the subsequent directories that you will encounter during execution. Q23. Is there a limit to the number of characters that are will be included in the directory path/name? [SJ] Safe to assume maximum 4096 characters would be given in a command. Q24. In the document given for mp1 at all hop instructions absolute paths has been printed but answers to Q19,Q18 are contradicting with what is given? Kindly tell what to do finally or both are allowed and we can mention this in readme(giving different instruction is not only making us revisit this specification again and again and we have to change code for the particular instruction again and agian even after implementing the instruction long back) In all the hop commands abs path has been printed(ps cant attach image kindly check with the orignal doc given on the course page) [SJ] ![Screenshot 2024-08-20 at 7.22.12 PM](https://hackmd.io/_uploads/rkc9kXGs0.png) As you can see in the given image. When you are entering a command there is a path along with username. Ans 6 tells you about this path which is alongside the username. After you give command hop test , absolute path of `/home/johndoe/test` is printed . Here you always need to print absolute path. [KM] Q18 has been updated to resolve this contradiction. Apologies for the error. Q25. What should be done if the command : hop . ; hop - is performed as the first input command? [SJ] `hop .` makes your previous directory also current directory. Then `hop -` takes you to previous directory which is the original directory before executing the command. Q26. Just confirming… so after every hop command , the absolute path should be printed as per the command right? [KM] Yes. Q27. If hop with no arguments is given should we hop into home directory of the shell code? [KM] Yes. The "home directory" as mentioned in the requirements document, for all intents and purposes, refers to the home directory of the shell code. Q28. Are we supposed to run hop as a function or a process? To be more specific, if we input the command hop .. & should hop run as a background process? [KM] You are not expected to handle running of user-defined processes (reveal, hop, log etc.) in the background. This has been mentioned in the mini-project document, as a note right under Spec-6's "background" specification. Q29. If my shell code is the Downloads folder of my system , so when I execute hop somefolder (which is inside my shell folder)command from where my shell code is present ,then I need to print absolute path (i.e home/username/Downloads/shellcode/somefolder) but in prompt i need to display ~/somefolder> . Is this correct? And If I want folder which is outside my shell code (suppose folder from Document folder ) then what can be done ? [AA] Yes for the first part. For the second one, you can use the absolute path in both the prompt and when you print it. Q30. DO we need to handle hop ../.. like cases? [KM] Yes. Q31. From the answer of Q13, if /home/user/Documents/sem3 is the directory from which shell is invoked, then this is is the home directory, now if we do hop . shouldn't we show /home/user/Documents/sem3 are we not allowed to show the absolute path when hop . is executed? [KM] Indeed, you should show /home/user/Documents/sem3. Apologies for the error, this has now been corrected in Q13. `hop` is always supposed to print the absolute path. Q32. Is ```hop /home/user/Documents/sem3``` valid command? If so, then there are three possible ways of giving this command ```hop test``` and ```hop ~/project``` and ```hop /home/user/Documents/sem3``` ? [KM] Yes. Yes. This has been mentioned explicitly in the specification document: > You should support both absolute and relative paths, along with paths from home directory. Q33. Follow up for Q30, only hop ../../.. kind of commands are valid or hop ../. is also valid? and any more extra commands which are need to be handled in this type? [KM] Re-iterating this again (Refer to Q13 where I've mentioned that you can do this in a generalised way), *you are not supposed to hardcode all such cases!* But yes, the cases you've mentioned are all valid. **Any valid relative path format that is acceptable by bash should be supported by you in your shell.** Q34. hop path and hop path/ should we handle both the cases? hop ~/path and hop ~/path/ ending with '/' [KM] Yes. If bash supports it with `cd`, you have to handle it. Q35. Is this hop /home/user/Documents/path/../.. valid? [KM] Yes. If bash supports it with `cd`, you have to handle it. Q36. For hop ../../. we should print 3 absolute paths, right? [KM] No. Q37. If hop ~/path is given should it print the following: /home/user/Documents (home directory) /home/user/Documents/path or just the final one /home/user/Documents/path [KM] ![image](https://hackmd.io/_uploads/HkcTPoaoR.png) Refer to the spec sheet before asking a question. Q38. Can we use realpath function? [KM] Yes. Refer to the FAQ at the bottom of this sheet. Q39. If our first command is hop t1 -, is the previous directory defined as path to t1? [KM] Make reasonable assumptions and mention them in your README. Q40. In case like hop ../test the previous directory would be parent of test as we are first going to the parent and then to test? [AA] Quoting the spec doc: > <JohnDoe@SYS:~/test/tutorial> hop ~/project /home/johndoe/project So you're expected to pre-process the `..`, `.`, `/` (root), and `~`. Try not to ask already answered questions. Q41. After the symbols ..|.|~ space would be given for another file or atleast the /symbol? [AA] `hop ..tutorial` and `hop ../tutorial` and `hop .. tutorial` would have different outputs, yes. (The latter 2 will achieve the same result, but see Q40 for differences in output between them). Q42. Can we use <libgen.h> ? [KM] It is [POSIX](https://en.wikipedia.org/wiki/POSIX) compliant, so yes. Q43. If executing `hop abc -/123` then the `-` hyphen in the second argument refers to the directory where it was before this command (i.e hop abc is essentially discounted, unless `123` is an invalid directory). is this okay? [KM] You are free to decide how you'll handle this scenario. Mention this in your README. # Spec 4 Q1. How do we differentiate between hidden and non-hidden files? Is a file hidden if it has a . in front of its name, and the rest of the files are non-hidden? [IG] Yes. Q2. Can we use grp.h for getting the group name of a file / directory? [SJ] Yes Q3. Are we also supposed to print total x at the top of all the list of files while doing reveal -l? [SJ] Yes. Q4. Are flags always present and what does reveal - outputs is it the contents of current directory or files of directory after hop -? [AA] Flags may not always be present. For '-', output the contents of the previous working directory; note that you are not supposed to hop to it to do so. Q5. Can we assume that the reveal will be only called on directories and not on files, or should we be displaying the details of the file also? [DP] You should display just the details of the file if reveal is called on a file. Here is an example : ``` <JohnDoe@SYS:~> reveal -l watch.jpeg -rw-rw-r-- 1 user user 38852 Jul 3 19:01 watch.jpeg ``` Q6. What should be the output of `reveal -lala <path/name>`? [KM] Same as `reveal -la <path/name>`. Multiple repeated flags should be treated as a singular invocation of those flags. Q7. Should `-al` and `-la` and `-a -l` give the same output? [KM] Yes. `-al`, `-la`, `-a -l`, `-l -a`, `-alal`, `-lllla`, `-l -a -l -al` are all equivalent, and should trigger `-l` and `-a` flags. Q8. are we allowed to use opendir,readdir function [DP] Yes. Checkout <a href = 'https://karthikv1392.github.io/cs3301_osn/mini-projects/mp1#useful-commandsstructsfiles'>Useful commands/structs/files.</a> Q9. are we allowed to use stat [DP] Yes. Refer resource in Q8. Q10. if the order of files getting printed in ls-l and reveal -l is different is it fine [DP] You are expected to print the files lexicographically in the mini-project document which is what `ls -l` also does implicitly (if `ls -l` does not display lexicographically in your distro you should print it lexicographically anyhow). Q11. is reveal ~ and reveal .. a valid command or we need to specify flag [DP] It is valid. Q12 .Is colour coding compulsory ? [DP] Yeah, it is. It isn't that difficult to do and gives a professional look so why not :) Q13. If the input command is something like reveal -al - or reveal - but there is no previous directory should it print an error statement like in hop? [IG] reveal -al is not same as reveal -. If there is no previous directory, you should print an error statement like hop. Q14 . should we handle cases where there are spaces between the flags like reveal -a -l ,reveal -a -la -al,etc..? [DP] You should handle it since you are already handling cases like `reveal -a -l` so there should be a generalization of the entire argument space (i.e, any combination should work). Q15. If reveal - is performed but there are no previous directories what to do? [DP] Print an error/warning and mention it in your README. Q16. Please give an example of command involving both -a/-l flags as well as the flags used for hop command. [AA] This question was posted in Spec 4 -- reveal. There are no -a/-l flags defined for hop. For reveal, the flags have been explained already. Q17. If the input command is like reveal .. or reveal . should the output be that of ls .. or ls .? [AA] I'm not sure I understand the confusion -- why wouldn't it? Q18.<b>Edited question :</b> Is `reveal -a .. test` a valid command? [SJ] Clearly written in doc that multiple arguements will not be given. Q19. Is reveal <path/name> a valid command or will flags be always given in the input? [SJ] Flags may or may not be present. `reveal <path/name>` is a valid command. Q20. Should colour coding be performed for reveal -l command as well(since in the original terminal the colour coding is performed only on ls -a and ls -al commands)? [SJ] Should be done for all flags. Q21. How many files(all executables,files,folder) a directory can have? Needed to know for creating a storage array. [SJ] You can assume 1000 maximum entries to be present in a directory. **Please mention this in your README.** Q22. If reveal -l ; reveal - command is performed as the first input command what will the output be? [KM] Typically, the `$OLDPWD` environment variable, which is responsible for handling the previous working directory changes only when you first call `cd`. In this case, assuming you haven't called `hop` before calling `reveal -`, you can choose to simply raise an error mentioning that no previous working directory exists (or whatever error you're raising for `hop -` as your first *hop*). **You are free to handle this however you'd like to. Just be sure to mention what you're doing in your README, and also mention the question number of this doubt.** Q23. If -l flag is present in the input command should the colour coding reflect on the entire details of the file or should it reflect only the file or directory name? [KM] Up to you to decide. `ls -l` colors only the name of the file/directory/symlink/..., so you can choose to do the same. Alternatively, you can colour all the details. **Please mention what you're choosing to do in your README.** Q24. In my terminal in pop os when I typed ls -a I did not get all the hidden files first. Instead they are like this ![image](https://hackmd.io/_uploads/rkDZuKXjA.png) Is it okay to write the code so that my files are in this order or all hidden files first then the remaining files in lexicographical order? [KM] Simply print in the [lexicographical order](https://en.wikipedia.org/wiki/Lexicographic_order) -- you do not need to additionally handle cases such as this. For example, if you have the following files: `.git, Downloads, documents, README, hello`, then the order would be `.git, Downloads, README, documents, hello`. Q25. When reveal - is performed should we print the hidden files as well? [KM] No. Print the hidden files only when the '-a' flag is used. Q26. Is 'reveal -lala - a' valid command? [KM] No. Spacing between a '-' and a 'a' should result in the '-' being treated as relative path for previous working directory, and the 'a' being treated as an additional path parameter -- but reveal takes only 1 path parameter. On the other hand however, `reveal -lalala -a -l` is valid. Q27. for reveal -l or reveal -a or reveal -la, it is fine if we print the absolute path of the file/dir? or do we have to print just the file/dirname? [KM] You are expected to do what `ls` does -- print just the file/dirname. Q28. in q3 you have mentioned we have to print total x what is this x number of files we read(in ls in bash this is different). [KM] This is the total number of blocks of the directory. Typically, `stat` returns this in 512 byte chunks. It is perfectly fine if the number you're getting is half of that shown in `ls`. Just print the total number of blocks in the directory. Q29. is "reveal -al .." a valid command or only "reveal .." is valid ? [KM] Both are valid. Q30. The project document asks us to color code executables in green. What exactly does 'executable' mean here? A binary file, or any file that has execute permissions? If it's the latter, do we need execute permissions for the user, group, or others, or all three? [KM] Any file with execute permissions is considered to be an executable. As for your second question, for the file to be treated as an executable, "User" at the very least should have executable permissions. This is the minimum requirement for **you** (as a **user**) to be able to *execute* a file in bash as well. Q31. Can you explain the role of reveal - Should it reveal the files present in the directory obtained on doing hop - or is it something else [KM] Reveal the files present in the directory obtained on doing hop - (the previous working directory), but don't actually hop to that directory. Q32. from ref q5 so if the file is given as a input the filename is given or its path i.e can we give absolute will be given ? [KM] **Please rephrase your question and post another doubt.** Q33. Should we need to print permissions also if -l flag is added to command,as in bash -l flag also print permissions? [KM] ![image](https://hackmd.io/_uploads/SkCsKoToC.png) Refer to the specifications sheet before asking a doubt. Q34.can we use scandir function? [KM] Yes. Refer to the FAQ at the bottom of this doubts document. Q35. "If no argument is given, you should reveal at the current working directory" so is this a valid command : reveal -a? it reveals at the current directory with -a flag? or just reveal? [KM] Reveals at the current directory with -a flag. Q36. Should our lexiographical ordering be case-sensitive? [KM] Yes. Refer to Spec 4 Q24. Q37. Can/should reveal -a show . and .. as options in the list? [KM] Yes. Q38. Do spaces in between matter? in reveal -l *Edit*: If we do ```reveal -l``` and we got the following ```-rw-rw-r-- 1 usr grpname 2 Aug 13 16:34 a.txt``` do no. of spaces in between -rw-rw-r-- and 1 matter? [KM] No. # Spec 5 Q1. If the command consists of multiple commands seperated by ; do i store this entire command in the history or each individual command and if any one of these is erroneous do i discard the entire string? ~~[IG] Treat as multiple commands.Only discard the erroneous command(s) and not the entire string.~~ [KM] **(Edited:)** Store the entire command in history. Do not worry about erroneous commands in the string, store it regardless. Q2. Are we allowed to use `write()` or `read()` commands? [DP] Yeah, you can use that. Q3. Is it fine if the input is something like reveal<multiple spaces>-l and we store reveal -l (only 1 space) in log? [DP] No, you are expected to store the command as given by the user. Checkout `history` command in the terminal with the same testcase to see how it stores the commands. Q4. Regarding Q3 above what about commands like hop .. test where test fails? [DP] **(Edited:)** You are expected to hop sequentially till it's valid, but store the entire command as is. ~~but treat the command as erroneous.~~ Q5. How are we supposed to store hop .. test? [DP] Refer Q4. Q6. Is it necessary to create a text file for log or can we use an array or any other data structure in C to store it? [DP] You need to store it in a file for persistence ie, the commands should be stored across multiple terminal sessions. Refer the mini-project document. Q7.(From Q6) We can do this without using file, and just using array right? [KM] If you think that you can do it with just an array without using a file for storage, then please go ahead. As long as you are able to store the commands across multiple terminal sessions, you are good to go. **You can implement it however you like.** Do note that "multiple terminal sessions" in this case includes cases where even if I close the shell, (optionally) turn the computer off and boot it up a couple of minutes/hours/days/weeks/months/.. later, and open the shell, my logged commands should still be visible. Q8. Do we take care of & or ; while storing commands? If yes then what about the ones which have no flags? [KM] **(Edited:)** *Refer to Q1*. ~~In essence, tokenize the commands as you normally would, store each tokenized **valid** command as a separate command as entered by the user (even in cases of multiple repeating flags or no flags). As long as the command is valid, you store it.~~ Q9. (Regarding Q8) Do we keep track of & or ; in logs? Let's say we had command1 & command2, then when we use log execute to rerun the command1 should it run in foreground or background? And how do we store them? ~~[KM] command1 should run in the background. You can store it as `command1 &`. command2 should run in the background, and can be stored as `command 2`. Even if you had something like `command1 & command2 ;`, you can store command2 as `command2`, since the `;` is merely a separator in this case. However, it is perfectly fine even if you store `command2 ;` as is.~~ [KM] **(Edited:)** command1 should run inthe background, and command2 should run in the foreground. So yes, keep track of & and ; in the logs. Simply store the entire command as `command1 & command2 ;`. Q10. Will sleep ; and sleep & be treated as the same process? Like if log has sleep which was executed as sleep & and the next command entered is sleep ; will they be considered as different processes and another sleep will be added to the log or will it be treated the same and log wont be updated? [SJ] No the 2 commands are different. sleep ; and sleep & will be treated as different processes and another log will be added. Q11. Will commands like `reveal <one space> -l` be treated the same as `reveal <two spaces> -l`? ~~[SJ] They will be treated as same.~~ [DP] It is performing the same thing essentially but stored differently in log. Remember `history` command in bash stores the commands as input by the user so number of spaces have to be retained. Q12. If the user gives a command like hop ; echo "hello", can we store the two commands separately in the log file i.e. 1 hop 2 echo "hello" or do we have to store it in a single line as given by the user. ~~[KM] *Refer to Q1, Q8, Q10.* These are separate commands, and must be stored separately in the log file. The output that you've given is correct. Do **NOT** store it in a single line.~~ [KM] **(Edited:)** *Refer to Q1*. Q13. Only the program will be able to change the log history? i.e - there would not be any hard cases where manually log history would be updated? Reason I am asking is this because different people can read log history in different pattern to give the same history?`method of storing the history can be different and on providing same input you will get different output.` [SJ] The log history will only be changed by your own shell or program . No case where manually log history could be updated. Q14. If I do hop dir1 but hop command is not successful in execution due to any reason then do we include this hop command in log If I have command1 ; command2 then in log should it go as single entry [DP] There are two questions here. <b>Decouple questions which aren't dependent.</b> ~~For first part - It should be an erroneous command and hence not stored in log.~~ For second part - Refer Q1. [KM] **(Edited:)** For the first part, store the entire command in the log even if it is erroneous. Q15. is there a particular order in which log should be printed(most recent coomand should be printed first or not compulsory) ~~[DP] The commands are ordered most recent to oldest (as mentioned in the mini-project document).~~ [KM] **(Edited:)** Bottom-up, log is supposed to be printed most recent to oldest (and this is the order of indexing followed for `log execute` as well.) However, when viewing it from top-down, log is printed oldest to most recent. Q16. in log execute do we need to store the command in log again(this will lead to duplication) [DP] If it’s the most recent command, don’t store it, otherwise store the command that was executed in log. <b>This statement has been directly cited from the mini-project document. It's important to go through the doc before asking doubts.</b> Q17. [duplicate] Q18. In the document when we give command log then oldest one is printed but answer for Q16 is opposite to it [AA] Please be more descriptive. Q19. in log execute if it is not most recent command then i have to store it again then my log will have the same command stored twice [AA] This is not an issue. The doc says nothing about forbidding the same command twice if they aren't consecutive. Please don't invent more requirements for yourself. Q20. (for Q18) In the screenshot from document on log we are printing the oldest command first (reveal test here)but answer to Q18 is opposite so please tell what is the correct way of printing. Answer to Q15 opposes this ![Screenshot from 2024-08-20 14-19-08](https://hackmd.io/_uploads/r1crgxMjC.png) [KM] Follow what is specified in the mini-project document. Top-down, oldest to newest. However, when `log execute` is run, `1` corresponds to the most-recent command. Hope this clears things up. *Q15's answer has been to reflect this.* Q21.We should consider `hop <one space> .. ` and `hop <multiple space> .. ` as different commands?As `echo "hello <multiple space>world" ` would be different from `echo "hello <single space>world"`? [KM] `history` in bash stores them as different commands. You are expected to store the command exactly as it is given by the user, so, yes, consider them as different commands. Q22. Can we use system(command)? [KM] No. This is mentioned as guideline 9 [here](https://karthikv1392.github.io/cs3301_osn/mini-projects/mp1#guidelines). Q23. Can we use exec? [KM] No. Q24. The answers to Q11 and Q21 are contradictory in my opinion. Could you clear that up? [DP] The answers have been edited to add more clarity. Refer to Q11 and Q21. Q25. So do we now store log commands? If yes then how do we store hop .. ; log execute 1 because if we store as it is and do log execute 1 after it it kills the process. And if not then how to store the give command? [KM] **(UPDATED:)** ****Do not store any command which uses 'log'.**** This means that you wouldn't store `hop ..; log execute 1`, nor would you store `hop ..; log`. Q26 is log execute 15 a valid command if yes what should be its output [KM] Yes, it is valid. The output is whatever the 15th command in log was, right before you ran log execute. Q27. in my implementation i am only printing 14 commands in log is it fine [KM] No. You have been instructed to print 15 commands, if >= 15 commands have been used ever since you started storing the logged commands persistently. Q28. Can we use fprintf? [SJ] Yes. Q29 Should we not store the erroneous log commands as well? [KM] Up to you. You can choose to not store them, or you can alternatively choose to store them even if they're erroneous. How you handle this is up to you, **please mention this in your README.** Q30. If we run log execute <index> then if the command present at <index> is hop .. then is it okay if hop is executed in the terminal and it goes to previous directory of our shell? [KM] Yes... this is precisely the expected behaviour. Q31. To execute commands like echo hello or sleep can we use execvp ? [KM] Yes, but this question is unrelated to spec 5. You will have to implement these system commands in spec 6 anyway. The example shown is supposed to work after you implement spec 6 as well. Q32. Can we define an absolute path for the .txt file being created ? [KM] Assuming that you mean the history file that you're creating, the implementation is completely up to you. If not, please post another question with more detail. Q33. In q32 I meant that can I create a .txt file in home directory of shell and update the commands in that file itself ? [SJ] Upto you mention in README. Q34. Do we need to clear the hisroty whenever shell is closed or should it be stored as it is even after opening new shell? [KM] ![image](https://hackmd.io/_uploads/BkRw9iaoA.png) Do not clear the history. Refer to the specifications sheet before asking a question. Q35. What is ```reveal -``` supposed to do? Is it the same as ```hop -``` ? [KM] Should expand - to mean previous working directory, yes. Q36. what is output of hop .. ; log ? should it go to parent directory nd print its path and then display log (excluding hop .. ; log)? [KM] Yes..? I'm not sure why this is a doubt. Q37. Can we hardcode the location of the file? [KM] Which file? and what do you mean by hardcoding its location? If you're talking about the history file, then it is entirely up to you. Q38: When we call `log execute index`, if we have a successful execution of a command should we store the executed code as the most recent log entry? [KM] ![image](https://hackmd.io/_uploads/r14dbi4nR.png) Q39: when there is ```log``` in multiple commands like ```hop .. ; echo "OSN" ; log``` the log will not be updated at all since log is present in the command string. what if there is ```log``` in some errorneous command example: ```loguio``` (error commands should be stored so this should be stored or as it contains 'log' it should not be stored?) [KM] `loguio` is not a valid `log` command. So store it. You would store `echo "log"` as well; you wouldn't discard it simply because it says log, it is NOT a `log` command. However, if you find the former too tedious, then simply make an assumption (that you won't be storing such commands), mention it in your README and proceed. Q40: `DO NOT store a command in log if it is the exactly same as the previously entered command.` Does previous command mean just previous command or all previous commands ? [KM] Just the previous command. # Spec 6 Q1. For the background functionality part, we are fine if the shell is interactive even when the process runs, or is there is something more to it? [DP]Yeah, the shell doesn't hand control to background processes so it is interactive (ie you can execute other commands). Q2. If we run a background process such as sleep 2 & and then we do not give any other command for the next 2 seconds. Then should the background process print the message of completion on its own or it should wait for the user to give some user input (any command) first and then print all the finished background processes. [IG] It should not wait for user input. Q3. For a forground process with multiple commands like say sleep 3 ; sleep 5 then first sleep 3 would be done and after that sleep 5. then after new promt come what we should we print sleep : 5s or sleep : 8s or sleep : 3s & sleep : 5s? [IG] sleep: 3s and then sleep: 5s should be printed. Q4. For background process when they start we print their pid(suppose pid is 1345 and process is sleep 3) then after process is ended and when we are printing exit status of process do we need to print sleep exited normally or is it fine to print something like process 1345 exited normally ? [IG] Print `sleep exited normally`. Q5. In continuation to Q3. how i can print first sleep 3s and then sleep 5s as time taken by command is needed to print with promt like this <JohnDoe@SYS:~ sleep : 5s> so how i can print two things one after other do i need to print two promts? is not it better to print total time taken? [KM] `<JohnDoe@SYS:~ sleep : 3; sleep 5: 8s>` would be ideal. You are free to implement this however you see fit, so **please mention whatever you end up doing in your README.** Q6. If we run some erroneous command on background should it run print pid and then print exited abnormally or we should just directly print comman is not correct or do some sort of error handling here? [KM] You can implement this however you see fit, **please mention whatever you end up doing in your README.** Ideally, you would print an error saying that the command is not valid, and not print the pid since the process should never start in the first place (this also means that you wouldn't print an exit status). Q7. Can we know what are the System commands that we need to implement exaclty, and can we use exec for implementing those ? (like emacs, gedit etc. What does etc include here) [KM] Any and all system commands supported by the Bash shell (except for special commands like cd) are expected to work in your shell. You do not need to implement these manually. There is a general way of getting all of these to work without having to account for every single one of them manually. Q8. Can we use system()? [KM] No. This has been explicitly prohibited by guideline 9 here. Q9. Can we call sh program to execute the system commands? [KM] No. Execute these commands directly, do not call a shell program to execute these commands for you. Q10. Are we required to handle case where there is starting quote for arguments ``` $ echo "hello there" ``` In my shell this gets considered as three arguments, when in bash it is two. Similarly if I have ``` $ echo `adfaf\nadsfaf` | wc -l 1 $ echo "hello\nthere" | wc -l 2 ``` This is based on spec 12, but relevant here too. Here if there is '\n' in backticks it gets rendered differently and hence gives different output. Shud we handle this. [KM] No, you are not required to handle this. Q11. Can we use `exec` ? [SJ] Yes Q12. Is glib.h allowed? [KM] No. Q13. > Whenever background process finishes, display message to user (after user enters any command, display all ended between last command run and this). This should come autonomously after the bg process has finished without any interaction with user. What does it mean?(Both the statements seem contradictory) Should we display ended process only after user enters something or immediately after the termination of that background process? [KM] This point has been reworded to make this clear. The ended process must be displayed immediately after that background process ends. Q14. Are we supposed to print/display an error if an & is placed at the end of a command that we've implemented? (for eg. hop, reveal) - as in if the command is "hop .. &" [KM] You are free to decide on how to handle this. **Please mention what you're doing in your README.** *This will not be tested.* Q15. > your shell will spawn that process but doesn’t hand the control of terminal to it kindly clarify, if the bg process outputs something are we supposed to show it on the terminal? also what do we do with interactive processes like vi ? For Ex. what should be the output of the following commands: ``` echo "Hello there" & ``` ``` vi & ``` [KM] Please check what `bash` does for the same. Your expected output should be the same as that from `bash`. Q.16 So according to the updated specification the background process prints the output and normal/abnormal completion message as soon as it finishes without any user interaction. But what if the user is typing something in the shell at the point or running some interactive foreground task like `vi` and a background process like `sleep 5` end. [KM] Doesn't matter if the user is typing something in the shell. In case of interactive foreground processes, bash sends the exit status of the previously ended jobs right after the interactive process ends. However, you are free to handle this however you'd like. Mention what you're doing in your README. Q17 Can we set a maximum limit of bgprocess to store the status of running bg processes for printing the success message? [KM] Yes. Set a high enough limit (atleast 4096) and mention this in your README. Q18. [duplicate] Q19. For executing system command if "~" is used do we have to use systems home or home of our shell( ie directory in which shell program is run ) [AA] `~` is a shell-specific expansion. So if you're executing a system command, feel free to report it as an error if `exec` fails. Q20. [unclear] Q21. can we use function like signal(SIGCHLD, childSignalHandler) ? for this part [KM] If you need it, then sure. Q22. The prompt we are printing after a fg process runs for more than 2s is it okay if the same prompt remains for the rest of the terminal session or is it necessary that it remains only for the immediate prompt after the fg process executed ?(the prompt <JohnDoe@SYS:~ sleep : 3; sleep 5: 8s>) [KM] Upto you. Mention it as an assumption in your README. Of course, it must change when a new process runs for longer than 2 seconds as well. Q23. Could u please explain [KM] Explain what? Q24. Rounding of till nearest integer means we have to round of 1.51 to 2 or would the floor work or both can be done? [KM] Either is fine. Mention it in your README. However, read: [Rounding to the nearest integer.](https://magoosh.com/gre/gre-math-rounding/) Q25. Can we create temporary files to store the command which the background process ran ? [KM] You are free to implement it however you see fit. Mention any assumptions in your README. Q26. Can we use execvp? [KM] Yes. Q27. Can we redirect the output of the background process using ```int fd = open("/dev/null", O_RDWR);``` [KM] You are free to implement it however you see fit. Mention any assumptions in your README. Q28. Can the output of the background process be printed at the prompt of the shell (as in the case of ```echo "hi" & ```in terminal)? [KM] You can choose to do whatever `bash` does. # Spec 7 Q1. For the status part of a particular process, are we required to implement the + (background process) functionality only for the processes started by our own shell, or for any process in the system? [KM] For any process in the system. Q2. Are we allowed to use getpgid()? [KM] Yes. Q3. is '+' is foreground process or background process? [SJ] Foreground. In given example R+ is there for shell. Q4. In executable path do we need to print relative path or we can print absolute path? [SJ] Anything would work. Q5. It is not mentioned what `proclore` actually does, can you please elaborate its functionalities? [KM] The example shown in the specifications document is sufficient. All it does is display the details of the process whose process ID is passed to it, else, it prints the details of the shell process. The required details are mentioned in the document. **Please check the document before asking a question.** Q6. The given example shows, for a process, `Virtual memory: 167142`. What exactly does this integer represent? [KM] Usually, it is represents the number of bytes of virtual memory that the process is using. However, you are free to represent the virtual memory in any units of storage. **Please mention the units you're using in your README.** Q7. For some processes, linux does not let us obtain paths to their executables. It says that permission is denied. Any suggestions to get past this? Or can we just report an error? [KM] You can report an error. Have you tried using `sudo` to see if that lets you get the path to the executables of those files as well? **Mention any assumptions you end up making in your README.** Q8. for Q7 in this we should not print the path rest all details should be printed am I correct? [KM] Yes. You can however choose not to display anything at all. Either way works. Mention what you're doing in your README. Q9. Can proclore take multiple arguments? If yes what if we get an invalid argument in between do we treat it similar to as we did in hop? [KM] Proclore cannot take multiple arguments. Please do not make up specifications (and make it harder for yourself in the process) that haven't been mentioned in the specifications sheet. Q10. Can we use popen? [AA] ![image](https://hackmd.io/_uploads/By8N_pRiR.png) **Read the spec doc** Q11. Does virual memory mean the total virtual memory allocated to the process, or the virtual memory the process is currently using? [AA] Quoting the answer to Q6 (emphasis mine): > Usually, it is represents the number of bytes of **virtual memory that the process is using.** **Please check if your question has been answered already** (especially since this section is short). That is the point of having a shared doubts doc -- so that common queries get resolved without you having to ask them. Q12. We can print states like I , etc which are present in the process stats? [AA] You can, but we will only check for the ones mentioned in the spec doc. Q13. Can we use readlink() to access info about processes for which permissions are denied (such as the shell)? [KM] Yes. We won't test for these cases though. Q14. Referring to the answer of Q7, how do I run `sudo` without using a system command? [KM] You can simply run the shell executable using `sudo`. # Spec 8 Q1. The question says for target: > You have to look for a file/folder with the exact name as this. But the example shows that "newfile.txt" matches "newfile" which is not an exact match. Are we supposed to do exact matching or should we ignore file extensions? [SJ] You can ignore file extensions. The given string should match a prefix of the file or folder. Q2. Are we required to search for normal files (regular files), or should we also be searching for system files and other files ? [SJ] Any file which matches the prefix of file being searched. Q3. We should search for files/directories in the present directory right?? [SJ] See Arguement 2 which is clearly specified. `The path to target directory where the search will be performed (this path can have symbols like . and ~ as explained in the reveal command). If this argument is missing, target directory is the current working directory. The target directory’s tree must be searched (and not just the directory).` Q4. What do we mean by 'print its output' in case of single file with -e flag. Does this mean to print the file of contents or execute in case of a executable file? ~~[SJ] You need to print the content of the file or execute in case of executable files if only a single file is found with -e flag.~~ [SJ] You need to print the content of the file if only a single file is found with -e flag. Assume executables will not be asked to search. Q5. I am using recusrion foe this spec so when i am running the command its taking a lot of time when the target file/folder is in sub(sub(sub)…) folder so is it fine? [KM] Yes, it's fine. Do consider exploring ways to optimise your approach, though :) (only if you have the time to do so, after you're done with all the specifications) Q6. Can the user also give a target with extension. Like `seek newfile.txt` ? [KM] Yes. Q7. Let say in our directory we have a file `newfile.txt` , `newfile1.txt` and a directory `newfile` then what output are we expected to print for `seek newfile`. [KM] All three. ``` <JohnDoe@SYS:~> seek newfile ./newfile ./newfile.txt ./newfile1.txt ``` Q8. Are we allowed to use ```nftw()``` for this specification ? [KM] Yes. Q9. Can you explain the role of seek - newfolder Now does target directory become that dierctory that is obtained by hop - or is the target directory the one that was last seeked into? [KM] Handle this however you'd like. Make reasonable assumptions and mention them in your README. Q10 Is seek - a valid command what should it do what about seek . [KM] No. Name of the file/directory to be searched is a MANDATORY argument. Q11 can i take the path length as 1024 [KM] The command length can be upto 4096 as mentioned multiple times earlier. Check Spec-2 Q8 for instance. Considering this, the path length can be longer than 1024. In any case, do not hardcode this; a better way would be to put this as a macro in your header file. Q12 suppose there is a file newfolder.txt and a directory newfolder now seek -e -f newfolder should print the output of file or not [KM] ![image](https://hackmd.io/_uploads/BknLk3aoC.png) It should. Q13 Do we need to handle multiple flags like needed for `reveal` also do we need to handle the multiple combinations like we did for reveal or would it be assured that the flags would be given in a correct manner? [KM] Considering that this hasn't been explicitly mentioned in the requirements document, you do not need to handle multiple combinations like `-ffee` etc. You are free to do so for the sake of completeness if you'd like. Q14. In regards to Q4, can we use exec to execute the executable file in this case? [KM] Referring to Q4 (edited), we won't be asking you to execute executables. Considering this, you are free to implement it however you see fit. Q15. Should seek "Search" "Path" work for absolute paths as well or is it sufficient if it works for relative paths? [KM] Should work for both relative and absolute paths. Q16.If absolute paths are also necessary(ref to q15) when the file/dir path is printed should its absolute path be printed or should the relative path be printed? [KM] Relative path of the file from the target directory. Q17. If seek -f name . is the input command then whilr printing the paths of files is it okay if absolute paths are printed? [KM] No. Print relative path of the file from the target directory. Q18. Multiple flags need not be handled in this case? [KM] Refer to Q13. Q19. On executing executables ELF is being printed will it be fine?(Cant find a way to remove it) [KM] It is fine. Q20.If I only want to implement Argument1, then I only look for the files in my cwd? Or look for the file/directory in the entire tree starting from the cwd or should it be entire tree starting from root or home? [KM] You are supposed to implement both. The *(optional)* part of argument 2 refers to that argument being optionally provided in the command. The absence of it would mean that you would only look for the files in your cwd. Q21: In the specifications document, it is given that: ![image](https://hackmd.io/_uploads/Sy0w8IxnA.png) However in Q1, 2, and 7, you have answered that any prefix match should be printed. Which one should we follow? [KM] Follow Q1, 2 and 7. Any prefix match should be printed. It is fine if you've already implemented what's specified in the specifications sheet. Q22. Can I use execl to execute the executables found in the tree? [KM] Refer to Q14. Q23. What does match a prefix of the file or folder mean does it mean if we enter seek h the path of hello folder in the current directory should be printed? [KM] Unclear question. Please rephrase it and ask it again. # Spec 9 Q1. Should we be able to create dynamic aliases based on the changes to the .myshrc file by the user ? Also if the answer is YES can we assume that any changes to the .myshrc file will be done using the correct syntax? [KM] No, you are not expected to create dynamic aliases. Similar to `.bashrc`, `.myshrc` should be executed at the start of a shell session. However, you are free to support dynamic aliasing if you'd like to :) Q2. Can we have our own language of code in .myshrc and then our own way how we execute it in our shell? [KM] No, supporting Bash is enough. (However, if you can make a [turing-complete](https://en.wikipedia.org/wiki/Turing_completeness) language, and write an interpreter/compiler for it, then please go ahead. Do note that you will also have to prepare documentation for the same. Do not use any [esoteric languages](https://en.wikipedia.org/wiki/Esoteric_programming_language) though! While this is a good standalone project, this is beyond the scope of this course. As a result, you won't be awarded any bonus marks for this, but you get brownie points for trying :D) Q3. Please make this specification more strong and strictly defined. For simplicity can i expect one line to contain only one alias or function prototype? Eg: ``` my_command = real command ``` I will search for an "=" in the line and if it exists its an alias. Similarly if there is a () in a line: ``` my_function() { do stuff "$1" "$2" } ``` I assume it is a function start. (and bracket must be in next line). Similarly have the double quotes in the command args, compulsary or other way. Doing so will make it a lot easier for us to make an interpreter, instead of doing some manual labour for days on, all that can be taught in courses like POPL instead. Some other suggestions would be to only have commands with arguments at the end. Eg: This won't be valid. ``` my_function() { do stuff "$1" "$2" | wc -l do stuff like "$1" fixed args } ``` [DP] The mini-project doc for this Spec has been updated to make life simpler. If there exist cases where there is ambiguity while defining valid syntax rules for the interpreter you can take necessary assumptions with the only requirement being that all assumptions be stated clearly in the README. Q4. Continuing Q1 means we jut have to create the aliases for the mentioned 4 functions only and user defined aliases are optional to implement? [KM] No, user defined aliases are NOT optional. This is not what dynamic (during runtime of the shell) aliasing means. You are supposed to create aliases for anything that the user defines. Q5. Do we need to support multiple arguments in functions? [KM] Yes. Q6. Do we need to support comments in the `.myshrc` file? [KM] Yes. Q7. To make our life easier, can we start a function with `func` keyword or something similar like the `alias` keyword for aliases? [KM] Yes, you can. Q8. Can you specify what hop_seek() does exactly? [KM] It is supposed to take only 1 argument. Just hop into the dir, and seek for files/directories in that directory with the same name as the directory that you just hopped into. Q9. Is it neccessary to support comments in the `.myshrc` file? or can we assume that there will be no comments inside atleast the function body? [KM] Simply ignore everything in any given line once you encounter a # in that line. Don't worry about edge cases such as us passing # as a parameter to the function itself. Q10. What should be stored in the log file? The alias or what it translates to? [AA] Do either and mention in README. Q11. Are we allowed to use the POSIX regex library by including <regex.h> [KM] Yes. Q12. Should the alias command also work as a background process? [KM] Not required, but you're free to do so if you'd like. Q13. If we have an alias like `logrec = log execute 1`, should our log file contain the command `logrec`? [KM] It doesn't need to, infact, it is not recommended to store this command (can cause an infinite recursion if logrec is called twice). However, you can handle this however you see fit. Q14. The "$1" in the example is just a placeholder, right? In the sense that we should replace it with some directory name in our .myshrc file itself? [KM] "$1" is a *[positional parameter](https://www.gnu.org/software/bash/manual/html_node/Positional-Parameters.html)* in bash. No, it is supposed to be set when the function is invoked from your shell with some directory name. For example, `mk_hop <dir_path_here>` is a valid invocation, where <dir_path_here> is a placeholder for some directory path (any directory path should work. You are expected to at least support absolute paths). Q15. Are we expected to implement functions which can take more than one argument? If yes, can an example be provided? [KM] You do not need to handle this case. Q16. Can exec system calls be used while implementing the bonus part? [KM] You can simply redirect that specific command to whatever your implementation in Spec-6 is. Q17. Do we need to allow user to add more functions or is it enough to handle the given two fucntions ? If so, can we just copy paste the given functions: ``` func mk_hop() { mkdir "$1" # Create the directory hop "$1" # Change into the directory } func hop_seek() { hop "$1" # Hop into this directory seek "$1" # search for files/directories with the same name as the directory you just hopped into. } ``` in .myshrc file and implement them ? [KM] No, you only need to support the above 2 functions. Do note that we will be checking for hardcoding (say for example, we could just change the "seek" in hop_seek() of .myshrc to reveal and see if the execution of this function changes in your shell). Q18. Can aliases have arguments? [KM] No. # Spec 10 Q1. is using pipe() system call allowed [DP] You are expected to use ```pipe()``` but it is needed for the next specification. Don't see why it's needed here. It isn't disallowed though. Q2. Can we use the functions used in spec 6 i.e., foreground background processes which uses exec functions?? Or are we expected to do this manually?? [DP] Yes. A good implementation would have let you handle it using the functions you wrote to handle system commands in spec 6 but wherever you want to run a system command you can use exec. Again, exec is disallowed to implement all new commands which you create. Q3. What should be the output in the following command `hop .. > newfile.txt` and newfile/txt contains `~`? [DP] The file gets created in the <i>initial</i> directory not latter and the output here being the path that you print after ```hop```. Q4. what should we do in case of `sleep < a.txt ; hop ..` and a.txt contains `2 & sleep 3 ; hop ..` . so should the command run like `sleep 2 & sleep 3 ; hop .. ; hop ..`?? [PS] The each sub command seprated by a `;` executes independently of other, in the order they appear. Since `sleep < a.txt` regardless of contents of a.txt would throw a error, since input redirection is not equivalent to function paramaters, thus provided example's output would be an error follwed by change in directory and corresponding output. Q5. Do we have to implement IO redirection for relative paths [KM] You do not need to handle this separately. Whatever works, works. Make sure that absolute paths work at the very least. Q6. Is echo"Something" & << newfile.txt a valid input? [KM] If it is not a valid input in bash, then it isn't valid here either. Q7. Can we assume '<' or '>' would not occur anywhere else (as in any name or command) ? [KM] Yes, you can assume that these special characters carry their special meanings always. Q8. What do you mean by no need to handle multiple input and output ? Does it mean that there would not be a more than 1 `<` and not more than 1 of `> and >>`? i.e - the first instance would work? [KM] You can assume that something like `cat < a.txt < b.txt` wouldn't be tested. However, something like `cat < a.txt; cat < b.txt` is still valid as these are 2 separate commands. Q9. What to do with commands like echo xyz > > newfile.txt? (Space in between >'s') [KM] You do not need to handle this case. `>>` is to be treated as a singular entity. Q10. Can we use `exec` since we need to handle commands like `wc`, ...? [KM] Ideally, you would redirect handling of these commands to whatever your handler from spec-6 was. So, yes. Q11. There is no need to handle files with names like `~/text.txt` only relative/absolute paths would be given for this case right? [KM] You only need to care about absolute paths for I/O redirection. Q12. Do we have to handle commands which were self implemented? For example, is the command `hop .. > newfile.txt` valid? [KM] Yes. I/O redirection and piping are supposed to work for BOTH user-defined and system commands. Q13. If we are required to handle cases like those mentioned in Q4, then commands like ```wc``` require a different implementation. Are we supposed to handle those separately, or do we need to keep it simple and just consider commands similar to the ones in the doc? [KM] No, they do not require a different implementation. Remember that you are doing an INPUT/OUTPUT redirection, you are NOT passing parameters. You are not supposed to handle these separately; your implementation should handle these cases out of the box. Q14. Should the command `hop < a.txt` and my 'a.txt' file contains ".."? Then should the final command `hop ..` be executed? And similarly for reveal and other functions which we have implemented in this project explicit? [KM] No. Refer to Q12 and Q13. Q15. Do we have to do input redirection only for `wc(word count)` as other functions like 'cd' and 'ls' dont accept inputs in the terminal like `cd < a.txt` and `ls < a.txt` where 'a.txt' contains any absolute/relative path? [KM] Firstly, you cannot exec `cd`. Secondly, the I/O redirection is supposed to be general, not command specific. Any command that takes an input/prints an output should support I/O redirection. Thirdly, refer to Q12 and Q13. Q16. Can I change the input redirection to the format `input.txt < command > output.txt` since it is easier to parse the command that way for me? [KM] No. It is supposed to work regardless of the order of < and >, and with an arbitrary number of spaces between each the command, < and >. Q17. Are we allowed to use `freopen()`? [KM] Yes. Q18. Is it fine if my command `echo "Hello World" > newfile.txt` ends up with the text in `newfile.txt` being `"Hello World"` instead of `Hello World`? [KM] Yes. Q19. If we have some command whose output is directed into `newfile.txt` but the command ends up erroring, should the error be printed in the terminal or `newfile.txt`? [KM] You can choose to handle this however you'd like (mention it in your README). Typically, you're supposed to print the error to `stderr` instead of `stdout`, and an output redirection is supposed to redirect only `stdout` to a file. Thus, considering that we haven't asked you to handle error redirection `2>`, you can print the error to the terminal. Q20. Regarding the answer for Q13, so is it our choice whether we want to handle **input redirection** or just arguments for the functions we have made? [KM] I am not sure what you're trying to ask here. Something like `cat -n < a.txt` where a.txt has `hello hi` should print `1 hello hi`. If you run `cat < b.txt` where `b.txt` has `-n hello hi`, then the output must be `-n hello hi` since the flag is not passed as parameter to `cat`, but rather, as an input that `cat` needs to read and process. *If this does not answer your question, please post another question with more clarity, preferably one with an example input and output of what you're trying to do.* Q21. Should commands like `echo i>newfile.txt text` work like they do in bash? [KM] **(EDITED)** No. You do not need to handle such cases. It is fine if you assume that the I/O redirection is used only at the end of the command and all its parameters. Mention this in your README. Q22. Follow up question for Q20, system commands are run by shell itself, so it knows whether the command uses arguments or supports input redirection as well. For user commands, there is no such rule. Thus, for user commands, do we have the choice to choose whether the command uses input redirection or only arguments? [KM] No. Please note that none of the user commands take any input, they simply accept flags and parameters. Considering this, input redirection doesn't do anything for user commands. Only output redirection is supposed to work for these commands. Q23. Would it be correct to assume that the format of any command would always be either command with args < input > output or command with args < output > input? [IG] The next arg after < will be input and after > will be output. They may occur in any order. Q24. When I run a command like `reveal -la > a.txt`, the ANSI colour codes I use make the output file look weird, like: ![image](https://hackmd.io/_uploads/H1TCyVhhC.png) Is this fine? Or are we expected to deal with removing colour codes depending on where the output file stream is, etc. [IG] Its fine. Q25. if i have a command like log execute 1 >> a.txt and command 1 is echo "hi" then it should print it in the terminal or in the a.txt ? [IG] It should print it in the a.txt since the log execute 1 is technically echo "hi" and echo "hi" >> a.txt prints the output in a.txt . Q26. Are we supposed to handle the cases where the format is ```echo "hi" > newfile.txt < wc``` ? [KM] I am not sure how you're redirecting input from wc. Please ask a new question with a valid command that actually works in bash first. Q27. Is it fine if ``` echo "hello<3-spaces>hi" >> z.txt``` gives output as "hello<1-space>hi" in the z.txt file? [KM] Yes this is fine. This is because you aren't required to handle quotes separately. Q28. Do commands like `echo hi|wc>newfile.txt|wc|wc` have to work? [KM] Yes. This is a perfectly valid command. Q29 .![image](https://hackmd.io/_uploads/BkKvp3gTR.png) Why did the first command `echo "Lorem ipsum" > newfile.txt` did not print anything while `echo "dolor sit amet" >> newfile.txt` printed the file contents . Isn't it wrong? because even in bash `echo "dolor sit amet" >> newfile.txt` does not print anything on the terminal. [KM] You're right. The second command is supposed to be `echo "dolor sit amet" >> newfile.txt; cat newfile.txt`. This has now been fixed in the project document. # Spec 11 Q1. In the following line of code do we need to execute till the end of the line or report an error right in the beginning about invalid use of pipes. `cat newfile.txt | wc |` [KM] You shouldn't execute this command at all. Simply report an error. Q2. Are we allowed to use temporary file? [DP] No, you can do this without temporary files Q3. Can we use the pipe() function? [DP] Yes. Q4. Can we use `exec` since we need to handle commands like `wc`, ...? [KM] Refer to Spec-10 Q10. Q5. What would hop..|echo output? [KM] Nothing. Even if you try `cat a.txt | echo` it would output nothing. Read [this](https://stackoverflow.com/questions/64773893/echo-stdin-confusion). Q6. Should `hop ..|wc` hop to the parent directory as well? (In bash, `cd ..|wc` doesn't change the directories) [KM] You can choose to do whatever, as this behavior differs from shell to shell. Mention what you're doing in your README. Case in point: **Fish** ![image](https://hackmd.io/_uploads/ry3PgwypA.png) **Bash** ![image](https://hackmd.io/_uploads/B1HYgPyp0.png) Q7. Should we run the commands in a pipeline sequentially or concurrently? The requirements of the specification state sequential execution (thereby not requiring forking) whereas the answer of Q13 of spec 12 would suggest parallelly running sub-processes are to be employed(which would require forking). [KM] The answer to Q13 of Spec 12 is the *actual* implementation of piping according to bash specifications. You do not need to do this, but it is fine even if you do. You can choose to run them sequentially, or concurrently. Please mention what you're doing in your README. Q8. Will marks be deducted if we use temporary files and then close them, so that the user never knows that the temporary files were used? [KM] Considering that we haven't imposed any restrictions on implementation, **no**, you will not lose any marks. However, this is frowned upon. # Spec 12 Q1. Can you please tell what is the expected behaviour in the following case ? `echo "Hello World" > newfile.txt | wc` [KM] ``` <JohnDoe@SYS:~> echo "Hello World" > newfile.txt | wc 0 0 0 ``` If you're wondering why this is the case, this is because wc needs an input coming into it in order to show the word count, however, an input redirection into a file does not implicitly print the contents of that file. *The following might be what you're trying to do:* ``` <JohnDoe@SYS:~> echo "Hello World" > newfile.txt | cat newfile.txt | wc 1 2 12 ``` **Note:** Unless explicitly mentioned otherwise, the expected behaviour is supposed to be the same as that from your bash/fish/zsh/... shell. **Edit:** The above is what `bash` outputs. Your output may vary, depending on what the default shell of your system is. Q2. is it necessary to handle ; and & separated in redirection and piping? [KM] Yes. For example: ``` <JohnDoe@SYS:~> echo "hi"; echo "hello" > newfile.txt; cat newfile.txt; echo "another one" > anotherfile.txt & cat anotherfile.txt hi hello another one ``` Q3. You mean spec 10 and 11 right? Is it a typo? > In short, you are required to make sure that Specification 8 and Specification 9 work when given as input together. [KM] Yes. Thank you for bringing this to our attention. This has been fixed on the website now. Q4. Let's say the command is: ``` echo `fasdfaf\nadfafd\n` | wc -l & ``` This uses a combination of & and |. For this bash seems to give the following output. ``` bash-5.2$ echo "fasdfaf\nadfafd\n" | wc -l & [1] 18329 bash-5.2$ 1 [1]+ Done echo "fasdfaf\nadfafd\n" | wc -l bash-5.2$ ``` But if i do it the other way around: ``` bash-5.2$ echo "fasdfaf\nadfafd\n" & | wc -l bash: syntax error near unexpected token `|' ``` In my current shell I am just tokenizing `wc`, `echo` as different commands, doing other way will get really complex. Are we really required to handle this? [KM] Yes. **(Additional clarification:)** You are expected to ensure that `&` works only for the command immediately preceeding it, not for the entire pipe as a whole. However, since bash itself applies the `&` to the pipe as a whole, it is fine if you decide to do this instead. *(Not recommended, since this would mean that you would have to implement backgrounding for custom commands as well.)* **Kindly mention what you're doing in your README.** Q5. Are we supposed to do backgrounding for pipes and redirection too? [AA] Yes. Q6. In my zsh shell the input command echo hello world > newfile.txt | wc the ouptut is 1 2 12 but in the answer of Q1 it was told that the output should be 0 0 0 and my code is also giving the input 1 2 12 in this what should be taken as the correct output? [KM] Either is fine. Whatever your system outputs can be treated as the correct output. Q7. Are we supposed to handle redirection and piping for hop,reveal,etc? [KM] Yes. Q8. Can we assume that & won't be given anywhere else in the command except at the of a command to specify that it is a background command? [KM] except at the *what* of a command? Please post another question. Q10. For background processes do we need to print the process id as in Q2 answer no pid was printed? [KM] Background processes are to be handled the same way as they were in Spec-6. So, yes. Q11. ```echo "hi" > file.txt | wc &``` what's the output of this command? like which runs in background ```echo "hi" > file.txt | wc``` or ```wc``` or is it our wish ex2:```sort < file2.txt | uniq & echo "Done" >> file1.txt``` which should run in background ```sort < file2.txt | uniq``` or ```uniq``` or our wish? [KM] Refer to Q4. Q12. Can we assume that & won't be given anywhere else in the command except at the end of a command to specify that it is a background command? How would the pipe work if a command in between is in background but the rest isn't, should it print an error. For example: ```echo "Hello World" > file.txt & | wc``` [IG] Print an error. You are not expected to handle such cases. Refer to Q4. Q13. Regarding Q1 : second example in the answer: According to the official bash documentation, "Each command in a multi-command pipeline, where pipes are created, is executed in its own subshell, which is a separate process (see Command Execution Environment)." (link:https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Lists:~:text=Each%20command%20in%20a%20multi%2Dcommand%20pipeline%2C%20where%20pipes%20are%20created%2C%20is%20executed%20in%20its%20own%20subshell%2C%20which%20is%20a%20separate%20process%20(see%20Command%20Execution%20Environment).) Therefore, the second example ``` <JohnDoe@SYS:~> echo "Hello World" > newfile.txt | cat newfile.txt | wc 1 2 12 ``` working as expected is a matter of chance (it may work sometimes based on system load and file size but is not guaranteed**). I implemented the commands separated by pipes concurrently in child processes. It prints 1 2 12 sometimes and 0 0 0 occasionally. Is this fine? ** https://teaching.idallen.com/cst8207/13w/notes/200_redirection.html#:~:text=The%20following%20command%20line,pipeline.%20Don%E2%80%99t%20do%20this. [KM] Great job figuring this out! Indeed, one of the fundamental rules of piping is that you are never supposed to use a file for both input and output redirection in the same pipe. We do not expect you to handle race conditions for these cases, and as such, this is perfectly fine. Q14. Is it okay to assume that there will be at least one whitespace character before and after `>`, `<`, `>>` and `|`? eg. can we have `echo hi|wc` print `hi|wc` and `echo hi | wc` print the word count? [KM] No. You cannot assume this. There can be an arbitrary number of whitespace characters (including 0 whitespaces). # Spec 13 Q1. Do we have to implement activities for custom functions also or just system commands? [KM] Considering the fact that you are not required to implement backgrounding of custom functions, you do not need to implement activities for custom functions. Q2. Do we need to implement activities function for background processes also(what should be displayed) [KM] I am not entirely sure how you plan on running `activities` when a foreground process is currently running (list of all the processes currently running that were spawned by **your shell**, i.e., in the current instance of the shell). Considering this, you need to implement activities function for background processes. Q3. In case a process gives an error while execution should it be added to activity list [KM] Up to you. Mention this in your README. Q4. We are expected to output the processes in "lexicographic order" but in the example vim was output before gedit. Why is that the case? The lexicographic order of what? [KM] Ascending order of PIDs, or, alternatively, you could choose to go with the lexicographic order of process names. Either of these is perfectly fine. Q5.Can we use qsort() ? [KM] Yes. Q6. From what I understand, activities prints only those background processes spawned by our shell which are still running or have been stopped due to SIGSTP signal (ping or ctrl-Z). Am I right? If that is the case, the processes which have terminated are not considered "stopped" right? [KM] You are right. Terminated processes are not "stopped", they simply are removed from your list of processes. Q7. What does it mean for a background process to be running? When I try to print activities, it always gives the state of all processes like sleep, vim, emacs, gedit etc as "sleeping". Even when I try to find the state of the process from bash, it still shows "sleeping". [IG] A background process is running if proclore(Spec 7) gives a R/S/Z status for it. You will always find the given commands' status to be "sleeping" on bash in background. Q8.Can we assume the number of activites to be stored at max 4096? [KM] Yes. Mention this in your README. Q9. Should background processes be stored over multiple terminal sessions or only the current terminal session is enough ? [KM] Only the current terminal session. Q10. In reference to Q7, if bash always shows process status as sleeping, then how are we supposed to show running, stopped or any other status for the processes? [KM] You can simply assume that a status code of 'T' implies stopped. Everything else can be considered to be running. Mention this in your README. Note that you're only required to display either stopped or running for this specification. Q11. Will it be fine if we store sleep rather than sleep time? Or both would work? [KM] I'm not sure what you're trying to ask here. I presume you're asking if you're supposed to store `sleep` or `sleep 5` if I run `sleep 5 &`. The answer to this is that you can choose to do whatever, but mention whatever you're doing in your README. Q12. Is it fine if we store foreground processes also but show only background ones?? Or show both?? [KM] I am not entirely sure how you will be displaying the list of foreground processes WHILE another foreground process is currently running in the shell. Do remember that you're required to store only those processes that have been spawned by your current shell session. Q13. I don't understand what exactly denotes a "Stopped" process. Commands that are asleep are considered still running, correct? Referring to your answer for Q10, would it be possible for you to provide an example of a command that ends up in state T? [KM] Any command that receives a signal of SIGTSTP (from Ctrl+Z) or SIGSTOP ends up in state T. # Spec 14 Q1. Which all signals we have to implement [KM] ![image](https://hackmd.io/_uploads/BkaHg-qnA.png) Q2. According to linux man page as well as on doing `kill -l` the signals which we get for 15 is `SIGTERM` while signal for 15 in the website is given for `SIGSTOP`? Kindly tell which is correct? ![image](https://hackmd.io/_uploads/ryhf2T23C.png) Upon `kill -l` ![image](https://hackmd.io/_uploads/BJ8H36n3R.png) [KM] You are right, signal for 15 is SIGTERM and not SIGSTP. Apologies for the oversight, this has now been fixed. Q3. Can you please provide with some testcases for Ctrl+Z [KM] You could try something like `vi` and then try to Ctrl+Z to send it to the background. Now, check `activities` to see if it has been stopped. Q4. Can we assume that Ctrl+Z will not be tested for commands like hop,reveal,etc.. ? [KM] Yes. Q5. When stop a process using ctrl+Z, and stop it using ping, should the terminal show that the process has stopped, similar to background processes? [KM] When you run `activities`, yes, it must show up as a stopped command. Q6. Can we implement `^C` (Ctrl+C) such that when no foreground process is running, it just invalidates the current line of input (which the user is still entering), empties the input buffer and prints prompt to take in fresh input? I find this very useful when I'm using bash/powershell and have typed something really long and can't practically backspace to erase everything. [KM] Sure. Mention this as an assumption in your README. Fyi, you can use the shortcut `Ctrl+U` to clear your current line of input in bash :) Q7. When we do ctrl+D and background processes exit do we have to print the exit status of process which we implemented in system commands or just exit and not print anything? [KM] Up to you. Mention this as an assumption in your README. Q8. Can we use kill command? [KM] I presume you're talking about the system call `kill()` and not the bash command `kill` (since you aren't allowed to use exec() for this specification). Assuming that you're talking about the former, yes. Q9. Can you please specify for which signals we have to keep the command to be stopped and for which signals we have to remove that from the list like we use 9 to remove and for 15 we have to print it as completed also can you give any equivalent command in terminal to test it? [KM] I think you've answered your own question, if not I'm not sure exactly what you're asking here. Please clarify what you mean by "for which signals we have to keep the command to be stopped and for which signals we have to remove that from the list"; what command? keep it where? which list? Q10. When stop a process using ctrl+Z, and kill it using ping, should the terminal show that the process has exited, similar to background processes? [KM] Yes. It is still a background process, and thus whatever you've done in Spec-6 still applies. Q11. Does `SIGCONT` (signal number 18) continue all processes or just the process whose id we have given? If it continues all processes, dowe have to ignore the pid part in `ping`? [KM] Just the process whose ID you've given. Q12. In the example, you've sent a SIGTERM signal to process 430, which means the process is terminated, not stopped right? As in, 430 shouldn't be present in the activities list anymore? ![image](https://hackmd.io/_uploads/B1DawS-TR.png) [KM] Please refer to [this](https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#:~:text=The%20SIGTERM%20signal%20is%20a,kill%20generates%20SIGTERM%20by%20default.). SIGTERM politely asks the process to terminate, but the process can choose not to terminate until it is brought to the foreground, or can even intercept this signal and do something else entirely. In this case, vim won't actually terminate until you bring it to the foreground, at which point it terminates immediately. On the otherhand, SIGKILL (9) forcefully terminates the process. Q13. Since Ctrl+D does not produce a signal and is rather EOF is it ok if we assume that ctrl D will be pressed only when no foreground process is running? [KM] Yes. Q14. Are we allowed to use `signal(), tcsetpgrp()` ? [KM] Yes to both. # Spec 15 Q1. Can we assume that we will be required to run the fg command for the background processes spawned by our terminal only. I think that it wouldn't be right to implement this for any general background process in the system? Am I correct in assuming this… ~~[AA] Just handle it in general, without dealing with whether it has been spawned by your shell or by something else.~~ [KM] **(Edited:)** You need to implement this only for background processes spawned by your own terminal. Q2. Here changing the state means to re-run the command itself right?? Or is it like we need to display the state as running. Also if we have to re-run what should activities display?? Say initially activities displays ``echo hii 8723 stopped`` and ```echo hello 9000 stopped``` Now if I say fg 8723 should I just append ``echo hii`` keeping the one with id 8723 intact or delete process entry with id 8723 append this?? [IG] You are not supposed to re-run the command but continue its execution as per the requirements in the specification. For your example, pid should not change. Q3. Here we are going to run a bg command in foreground so if its execution took more than 2 second. For Example sleep 20 was running in bg no i used fg to put in fg so in prompt should we prompt `fg : [ts]` or we need to wite `sleep : [ts]` [KM] You are free to do whatever. Mention this in your README. Q4. How can be echo "hello" can go to stopped state when running in foreground or background? [KM] It can't. It runs instantaneously and exits. I'm not sure why/how this is a doubt. The commands present doubt Q2 of this spec are simply random examples; they aren't correct. Q5. ``` Sleep 20 & Ping <pid> 19 Fg <pid> ``` In such case the command actually does not stop on doing ping due to this reason on again doing fg the command runs for a shorter time than 20 sec [KM] This is fine; and this is in fact expected behaviour with `sleep`. Read [this](https://unix.stackexchange.com/questions/658914/why-sleep-command-process-is-still-running-in-the-background-while-i-stopped-it). Q6. Sir is my output correct in this case? I did ``` sleep 50 Ctrl Z Bg <pid> Ctrl C ``` ![WhatsApp Image 2024-09-12 at 1.41.13 PM](https://hackmd.io/_uploads/H1IJu7g6C.jpg) [KM] No, this isn't correct. After bg 10692, sleep 50 is supposed to say "Running", as it is no longer stopped due to `bg`. In fact, it is supposed to be in the "S" state (Interruptible Sleep). Q7.for a background process what effect should Ctrl c and Ctrl Z have [KM] No effect whatsoever. Q8. If sleep x is currently running if ctrl d is encountered then is it fine if it logs out of our shell after execution of sleep 5, as there is no signal to detect ctrl d [KM] Yeah you can handle this case when a foreground process is running and Ctrl+D is called however you'd like. Mention this in your README. Q9. [KM] You only need to handle cases where the process has been spawned AND send to the background by your own shell. It wouldn't work otherwise. Apologies for the confusion. The answer to Q1 has been edited to reflect this. Q10. [KM] Running them in bg is pointless, and nothing should happen when you try to do so. Just try to emulate this behavior with your shell as well. # Spec 16 Q1. Suppose the time given as an argument is 4 seconds. During this interval a new process was created, it got executed and was reaped. So, should neonate print the pid of this process, or the pid of the most recently created process which is active in the memory after say 4 seconds? [KM] Neonate simply prints the pid of the most recently created process. It doesn't matter if this process has been killed in the meantime. Q2. What exactly is the relevance of the '-n' flag in this question? [KM] This flag is used to specify the interval (in seconds) before neonate prints out the latest created PID. Q3. Should we handle the case where the time interval given is 0? [SJ] Yes, Continuosly process ids should be printed. Q4. Any other flag needed to be handled here? [SJ] No. Q5. With respect to the below description: `The command prints the Process-ID of the most recently created process on the system (you are not allowed to use system programs), this pid will be printed every [time_arg] seconds until the key ‘x’ is pressed.` Do we need to stop the printing only when 'x' is pressed or should we also take care of the Ctrl + C and Ctrl + Z signals... [KM] Only when 'x' is pressed! So, you might want to disable Ctrl+C and Ctrl+Z processing for the raw mode :) *(Hint: there may be additional flags that you need to toggle)* Q6. Is there a default time interval to be assumed if `-n` flag is not used ? [KM] You can either do this, or simply return an error saying that args are missing. Please mention what you're doing in your README. Q7. Can i create a new directory where i store the processes and then traverse this directory when the command is called? [KM] You can, if you are certain that this will give you the correct answer for the last created PID. # Spec 17 Q1. The question says that we have to remove the headers, but the expected ouput prints the headers. What way should we be approaching this? Also is it fine if we remove all the empty lines, which are printed in the expected output? [KM] You have to remove the headers. **The expected output has been fixed to reflect the same.** Any further parsing you do on the output is up to you. Remember to mention any assumptions you're making in your README. Q2. Can we use wget and lynx for this specification?![Screenshot from 2024-09-07 20-29-45](https://hackmd.io/_uploads/HJwK9y5n0.png).Is this kind of output acceptable? [KM] You are NOT allowed to use exec/system/popen/pclose for this specification. You are expected to use sockets to retrieve the required data. Q3. [KM] Print whatever the website sends you when you send it a GET request. Q4. [KM] ![image](https://hackmd.io/_uploads/H1TyC1fTR.png) and ![image](https://hackmd.io/_uploads/HkZfAkGpA.png) # General Q1. Can we assume that the size for everything is at most 4096 characters? [IG] Yes. Q2. Can we use getenv and setenv functions? [IG] No. Q3. Can we use the commands like getcwd to get the current working directory? [IG] Yes. Q4. Should we handle piping and redirection? or is for future implementation? [IG] It is recommended to implement the specifications in part A for now. Q5. Does this have anything to do with our original kernel, I mean do we need to access the folders present on our laptops? Or is this a false shell? [SJ] You need to access the folders present on your laptops . Nothing like false shell. Q6. So, from Q4, if we do "hop test", if 'test' is not present in the directories, we should print an error right? [SJ] This is a doubt regarding Spec 3 . Refrain from asking these doubts in General Section . As far as answer yes you need to print an error . Q7. Can we use execvp anywhere except for SPEC 6? [DP] No, you are not allowed to use execvp anywhere except for running system commands. Q8.Can we safely assume that after a command there will be a space and then ; and then the next command [AA] No. There can be an arbitrary amount of whitespace (including none) between commands (this can also include a combination of tabs and spaces). You are expected to handle this in your tokenization. Q9. Can we assume the paths to files will not contain characters like ; and & [AA] You can. Q10. Can we make some extra files so that the code could be broken up in different parts? [SJ] Yes. [KM] Infact, you **should** be doing this! This is a good coding practice, and moreover, it is a requirement. At the very top of the mini project 1 document, we have mentioned: "As the scale of code will be very large, it is **necessary to write modular code. Do NOT write monolithic code.**" Do note that you **will be penalized heavily** if your code is not modular. The files that you create however, are up to your sole discretion. You can choose to make 1 file per requirement, or even multiple files to split up the code of a singular requirement. Q11. Can we have a single file but modular code? [KM] **No**. Do not do this. The whole point of modularity is to facilitate [reusability](https://en.wikipedia.org/wiki/Reusability), [scalability](https://en.wikipedia.org/wiki/Scalability) and [maintainability](https://en.wikipedia.org/wiki/Maintainability#Software). Writing your entire codebase in a singular file defeats the whole purpose. Furthermore, I quote the following directly from the mini-project document: "Following is the definition of what modular code should look like : your codebase must be separated in different C files based on the tasks that it is intended to perform. Create header files to include headers from C library." Q12. Can we choose whatever colors we want or do we have to follow the colors in the document? [AA] Follow the document where specified. Q13. There are too many screenshots from Copilot to be included in the ReadMe. Can I just directly show any relevant prompts on my laptop during the eval? (Yes, I understand storing screenshots is safer; but lite) [AA] No Q14. Do the error messages have to be exactly as shown in the document. All error conditions are not covered in the doc. I have a general format for error messages which does not match with the doc. (Will some script be run or will there be manual evaluations) [AA] There will be manual evals. Even if your error messages don't match exactly, if they satisfy the requirements it's fine. Q15. [AA] You can make changes (if you think they are needed) to your old submission, but only on the `final` branch. Q16. [KM] Yes. You do not need to handle such cases. Q17. [KM] 1. No clue, could be 30 mins, could be 1 hour. Depends on both; your own codebase, and the TA taking the eval. 2. Any unreasonable cases that even bash doesn't explicitly handle. 3. We are fairly certain that we haven't asked you to implement background for custom commands, infact, we told you multiple times that you DO NOT need to. 4. Please refer to the highlighted guideline below. ![image](https://hackmd.io/_uploads/rJ1O5yfpR.png) *FAQ:* Can I use function X? [AA] ![image](https://hackmd.io/_uploads/SkO2jt6sA.png)