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??
Q2. Can we use fgets()?
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?
Q4. Are we free to use commands other than mentioned . Like , can we use gethostname()?
Q5. To go to parent directory we should execute cd .. right ? does it mean we should implement cd functionalities?
Q6. Are we allowed to use strcspn?
Q7. Are we expected to handle cases like "echo "Hello" > file1.txt > file2.txt > file3.txt" ?
Q8. Are we expected to handle cases like "command < input.txt > output.txt 2> error.log" ?
mem mem
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?
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?
Q3.Can we Use execvp ?
Q4. Will we have only one & and one ; or multiple & and ; Also can we use execl??
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??
Q6. How should our shell handle cases when multiple lines are entered as a single command? Different shells handle this differently.
For example if
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?
Q.7) Will space be given after ;
, &
in input?
Q8. What should be considered as the maximum input length?
Q9. Can & operation be combined with our custom defined functions For example can we get log & hop dir1
Q10. Can there be more than one spaces between commands eg hop Dir1
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.
Q12. Do we need to handle multiple background processes as well? (example-command1 & command2 & command3)?
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 ; > >> < ~
?
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?
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?
Q2. Can it be safely assumed that the absolute paths to be handled will be starting with '/' (the root) or something like '/home'.
Q3. Do we need to check if the required directory to which we have to hop in the specified relative / absolute path exists?
Q4. Can we use chdir()
?
Q5. Are we allowed to use S_ISDIR
function to check if specified directory exists or not?
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 ?
Q.7 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?
Q8. If we encounter a command like hop dir1 dir2 and if dir2 fails do we still execute the hop dir1 or not?
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?
Q10. If I am in the directory from which shell is invoked and I do hop .. it should stay in the same directory right??
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
Q12.
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 - ?)
Q13. What does hop. do? just print the name of the current directory or change the directory to parent directory or this work is done by hop.. ?
Q14. What does hop - do?
Q15. then what is difference between - and ..
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)
Q17. Can we use 'getpwuid' function?
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)
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?
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?
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)?
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?
Q23. Is there a limit to the number of characters that are will be included in the directory path/name?
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)
Q25. What should be done if the command : hop . ; hop - is performed as the first input command?
Q26. Just confirming… so after every hop command , the absolute path should be printed as per the command right?
Q27. If hop with no arguments is given should we hop into 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?
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 ?
Q30. DO we need to handle hop ../.. like caes?
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?
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
?
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?
Q34. hop path
and hop path/
should we handle both the cases?
hop ~/path
and hop ~/path/
ending with '/'
Q35. Is this hop /home/user/Documents/path/../..
valid?
Q36. For hop ../../.
we should print 3 absolute paths, right?
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
Q38. Can we use realpath function?
Q39. If our first command is hop t1 -
, is the previous directory defined as path to t1
?
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?
Q41. After the symbols ..|.|~
space would be given for another file or atleast the /symbol?
Q42. Can we use <libgen.h> ?
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?
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?
Q2. Can we use grp.h
for getting the group name of a file / directory?
Q3. Are we also supposed to print total x
at the top of all the list of files while doing reveal -l
?
Q4. Are flags always present and what does reveal - outputs is it the contents of current directory or files of directory after hop -?
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?
q6. What should be the output of reveal -lala <path/name>
Q7 should -al and -la and -a -l give the same output
Q8. are we allowed to use opendir,readdir function
Q9. are we allowed to use stat
Q10. if the order of files getting printed in ls-l and reveal -l is different is it fine
Q11. is reveal ~ and reveal .. a valid command or we need to specify flag
Q12. Is colour coding compulsory ?
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?
Q14 . should we handle cases where there are spaces between the flags like reveal -a -l ,reveal -a -la -al,etc..?
Q15. If reveal - is performed but there are no previous directories what to do?
Q16. Please give an example of command involving both -a/-l flags as well as the flags used for hop command.
Q17. If the input command is like reveal .. or reveal . should the output be that of ls .. or ls .?
Q18. Is reveal -a .. test
a valid command?
Q19. Is reveal <path/name> a valid command or will flags be always given in the input?
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)?
Q21. How many files(all executables,files,folder) a directory can have? Needed to know for creating a storage array.
Q22. If reveal -l ; reveal - command is performed as the first input command what will the output be?
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?
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
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?
Q25. When reveal - is performed should we print the hidden files as well?
Q26. Is 'reveal -lala - a' valid command?
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?
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).
Q29. is "reveal -al .." a valid command or only "reveal .." is 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?
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
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 ?
Q33. Should we need to print permissions also if -l flag is added to command,as in bash -l flag also print permissions?
Q34.can we use scandir function?
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
?
Q36. Should our lexiographical ordering be case-sensitive?
Q37. Can/should reveal -a
show .
and ..
as options in the list?
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?
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
Q2. Are we allowed to use write()
or read()
commands?
Q3. Is it fine if the input is something like reveal<multiple spaces>-l
and we store reveal -l
(only 1 space) in log?
Q4. Regarding Q3 above what about commands like hop .. test where test fails?
Q5. How are we supposed to store hop .. test?
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?
Q7. (From Q6) We can do this without using file, and just using array right ?
Q8. Do we take care of & or ; while storing commands? If yes then what about the ones which have no flags?
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?
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?
Q11. Will commands like reveal <one space> -l
be treated the same as reveal <two spaces> -l
?
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.
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.
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
Q15. is there a particular order in which log should be printed(most recent coomand should be printed first or not compulsory)
Q16. in log execute do we need to store the command in log again(this will lead to duplication)
Q17. while storing a command in log we only have to check whether it is duplicate to previous command or all the commands in the log
Q18. In the document when we give command log then oldest one is printed but answer for Q16 is opposite to it
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
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
Q21.We should conisder 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"
?
Q22. Can we use system(command)?
Q23. Can we use exec?
Q24. The answers to Q11 and Q21 are contradictory in my opinion. Could you clear that up?
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?
Q26 is log execute 15 a valid command if yes what should be its output
Q27. in my implementation i am only printing 14 commands in log is it fine
Q28. Can we use fprintf?
Q29 .Should we not store the erroneous log commands as well?
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?
Q31. To execute commands like echo hello or sleep can we use execvp ?
Q32. Can we define an absolute path for the .txt file being created ?
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 ?
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?
Q35. What is reveal -
supposed to do? Is it the same as hop -
?
Q36. what is output of hop .. ; log ? should it go to parent directory nd print its path and then display log (excluding hop .. ; log)?
Q37. Can we hardcode the location of the file?
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?
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?)
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 ?
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?
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.
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
?
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
?
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?
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?
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)
Q8. Can we use system()
?
Q9. Can we call sh
program to execute the system commands?
Q10. Are we required to handle case where there is starting quote for arguments
In my shell this gets considered as three arguments, when in bash it is two.
Similarly if I have
This is based on spec 12, but relavent here too. Here if there is '\n' in backticks it gets rendered
differently and hence gives different output. Shud we handle this
Q11. Can we use exec
?
Q12. Is glib.h allowed?
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?
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 .. &"
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:
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.
Q17 Can we set a maximum limit of bgprocess to store the status of running bg processes for printing the success message?
Q18. If there are multiple commands, such as sleep 5; sleep 3; sleep 4
, how should the prompt be displayed on the next line?
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 )
Ex : ls ~ : should it print ls for home directory or our shell home
Q20. can we use signals ?
Q21. can we use function like signal(SIGCHLD, childSignalHandler) ? for this part
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>)
Q23. Could u please explain
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?
Q25. Can we create temporary files to store the command which the background process ran ?
Q26. Can we use execvp?
Q27. Can we redirect the output of the background process using int fd = open("/dev/null", O_RDWR);
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)?
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?
Q2. Are we allowed to use getpgid()?
Q3. is '+' is foreground process or background process?
Q4. In executable path do we need to print relative path or we can print absolute path?
Q5. It is not mentioned what proclore
actually does, can you please elaborate its functionalities?
Q6. The given example shows, for a process, Virtual memory: 167142
. What exactly does this integer represent?
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?
Q8. for Q7 in this we should not print the path rest all details should be printed am I correct?
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?
Q10. Can we use popen?
Q11. Does virual memory mean the total virtual memory allocated to the process, or the virtual memory the process is currently using?
Q12. We can print states like I , etc which are present in the process stats?
Q13. Can we use readlink() to access info about processes for which permissions are denied (such as the shell)?
Q14. Referring to the answer of Q7, how do I run sudo
without using a system command?
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?
Q2. Are we required to search for normal files (regular files), or should we also be searching for system files and other files ?
Q3. We should search for files/directories in the present directory right??
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?
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?
Q6. Can the user also give a target with extension. Like seek newfile.txt
?
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
.
Q8. Are we allowed to use nftw()
for this specification ?
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?
Q10 Is seek - a valid command what should it do what about seek .
Q11 can i take the path length as 1024
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
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?
Q14. In regards to Q4, can we use exec to execute the executable file in this case?
Q15. Should seek "Search" "Path" work for absolute paths as well or is it sufficient if it works for relative 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?
Q17. If seek -f name . is the input command then whilr printing the paths of files is it okay if absolute paths are printed?
Q18. Multiple flags need not be handled in this case?
Q19. On executing executables ELF is being printed will it be fine?(Cant find a way to remove it)
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?
Q21: In the specifications document, it is given that:
However in Q1, 2, and 7, you have answered that any prefix match should be printed. Which one should we follow?
Q22. Can I use execl to execute the executables found in the tree?
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?
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 ?
Q2. Can we have our own language of code in .myshrc and then our own way how we execute it in our shell?
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:
I will search for an "=" in the line and if it exists its an alias.
Similarly if there is a () in a line:
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.
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?
Q5. Do we need to support multiple arguments in functions?
Q6. Do we need to support comments in the .myshrc
file?
Q7. To make our life easier, can we start a function with func
keyword or something similar like the alias
keyword for aliases?
Q8. Can you specify what hop_seek() does exactly?
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?
Q10. What should be stored in the log file? The alias or what it translates to?
Q11. Are we allowed to use the POSIX regex library by including <regex.h>
Q12. Should the alias command also work as a background process?
Q13. If we have an alias like logrec = log execute 1
, should our log file contain the command logrec
?
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?
Q15. Are we expected to implement functions which can take more than one argument? If yes, can an example be provided?
Q16. Can exec system calls be used while implementing the bonus part?
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:
in .myshrc file and implement them ?
Q18. Can aliases have arguments?
Q1. is using pipe() system call allowed
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??
Q3. What should be the output in the following command hop .. > newfile.txt
and newfile/txt contains ~
?
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 ..
??
Q5. Do we have to implement IO redirection for relative paths
Q6. Is echo"Something" & << newfile.txt a valid input?
Q7. Can we assume '<' or '>' would not occur anywhere else (as in any name or command) ?
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?
Q9. What to do with commands like echo xyz > > newfile.txt? (Space in between >'s')
Q10. Can we use exec
since we need to handle commands like wc
, …?
Q11. There is no need to handle files with names like ~/text.txt
only relative/absolute paths would be given for this case right?
Q12. Do we have to handle commands which were self implemented? For example, is the command hop .. > newfile.txt
valid?
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?
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?
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?
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?
Q17. Are we allowed to use freopen()
?
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
?
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
?
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?
Q21. Should commands like echo i>newfile.txt text
work like they do in bash?
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?
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
?
Q24. When I run a command like reveal -la > a.txt
, the ANSI colour codes I use make the output file look weird, like:
Is this fine? Or are we expected to deal with removing colour codes depending on where the output file stream is, etc.
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?
Q26. Are we supposed to handle the cases where the format is echo "hi" > newfile.txt < wc ?
Q27. Is it fine if echo "hello<3-spaces>hi" >> z.txt
gives output as "hello<1-space>hi" in the z.txt file?
Q28. Do commands like echo hi|wc>newfile.txt|wc|wc
have to work?
Q29 .
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.
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 |
Q2. Are we allowed to use temporary file?
Q3. Can we use the pipe()
function?
Q4. Can we use exec
since we need to handle commands like wc
, …?
Q5. What would hop..|echo output?
Q6. Should hop ..|wc
hop to the parent directory as well? (In bash, cd ..|wc
doesn't change the directories)
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).
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?
Q1. Can you please tell what is the expected behaviour in the following case ?
echo "Hello World" > newfile.txt | wc
Q2. is it necessary to handle ; and & separated in redirection and piping?
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.
Q4. Let's say the command is:
This uses a combination of & and |. For this bash seems to give the following output.
But if i do it the other way around:
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?
Q5. Are we supposed to do backgrounding for pipes and redirection too?
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?
Q7 . Are we supposed to handle redirection and piping for hop,reveal,etc?
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?
Q10. For background processes do we need to print the process id as in Q2 answer no pid was printed?
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?```
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
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 command in a multi-command pipeline%2C where pipes are created%2C is executed in its own subshell%2C which is a separate process (see Command Execution Environment).) Therefore, the second example
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 following command line,pipeline. Don’t do this.
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?
Q1. Do we have to implement activities for custom functions also or just system commands?
Q2. Do we need to implement activities function for background processes also(what should be displayed)
Q3. In case a process gives an error while execution should it be added to activity list
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?
Q5.Can we use qsort() ?
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?
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".
Q8.Can we assume the number of activites to be stored at max 4096?
Q9. Should background processes be stored over multiple terminal sessions or only the current terminal session is enough ?
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?
Q11. Will it be fine if we store sleep rather than sleep time? Or both would work?
Q12. Is it fine if we store foreground processes also but show only background ones?? Or show both??
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?
Q1. Which all signals we have to implement
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?
Upon kill -l
Q3. Can you please provide with some testcases for Ctrl+Z
Q4. Can we assume that Ctrl+Z will not be tested for commands like hop,reveal,etc.. ?
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?
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.
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?
Q8. Can we use kill command?
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?
nom nom :)
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?
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
?
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?
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?
Q14. Are we allowed to use signal(), tcsetpgrp()
?
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…
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??
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]
Q4. How can be echo "hello" can go to stopped state when running in foreground or background?
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
Q6. Sir is my output correct in this case
I did
sleep 50
Ctrl Z
Bg <pid>
Ctrl C
Q7.for a background process what effect should Ctrl c and Ctrl Z have
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
Q9. The question 1 says that, fg command should work "in general" no matter if the process was spawned in our shell or not. But I observed that its not possible. Assuming everyone is using tcsetpgrp()
, if look at the manpage we find that EPERM flag is set when we try to do what is mentioned. Please give some clarification regarding this.
Additionally, I would advice the TAs to try to test the doubts given here in their shells etc, before typing out answers for here, and being vague like "implement in general".
Q10) terminal interactive processes (like vi, top, etc) cannot be run in background, in bash the process is stopped if we try to run it in background, Is it ok take an assumption to take that these commands wont be run in background using the bg command?
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?
Q2. What exactly is the relevance of the '-n' flag in this question?
Q3. Should we handle the case where the time interval given is 0?
Q4. Any other flag needed to be handled here?
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…
Q6. Is there a default time interval to be assumed if -n
flag is not used ?
Q7. Can i create a new directory where i store the processes and then traverse this directory when the command is called?
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?
Q2. Can we use wget and lynx for this specification?.Is this kind of output acceptable?
Q3. in the given example
this is present but in the website for sleep
there is no context of the above image was present in that website so do we need print asitis in the website or do u we need print the additional content also ?
Q4. Will it be fine if we dont print error message for the invalid commands and only the response of the page?
Q1. Can we assume that the size for everything is at most 4096 characters.
Q2. Can we use getenv and setenv functions.
Q3. Can we use the commands like getcwd to get the current working directory?
Q4. Should we handle piping and redirection? or is for future implementation?
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?
Q6. So, from Q4, if we do "hop test", if 'test' is not present in the directories, we should print an error right?
Q7. Can we use execvp anywhere except for SPEC 6?
Q8.Can we safely assume that after a command there will be a space and then ; and then the next command
Q9.Can we assume the paths to files will not contain characters like ; and &
Q10. Can we make some extra files so that the code could be broken up in different parts?
Q11. Can we have a single file but modular code?
Q12. Can we choose whatever colors we want or do we have to follow the colors in the document?
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)
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)
Q15. Bit confused here in part - B we have to implement the functions so are we allowed to change the files made for part - A? The reason I am asking is that in part - A we made the shell to be exclusively working for part - A but in part B we need to call some other functions (like ping) so it will definately need to be incorporated in the calling routine so we can change those files ? Am I thinking correct?
Q16. Just confirming we aren't required to handle cases where arguments such as "Hello World"
don't need to be considered as one argument and can be considered as 2? Same with 's/ //g'
being considered as two.
Q17. How long will an eval go for? When you say edge cases won't be tested, what exactly do you mean by edge cases? Because stuff like implementing backgrounding and pipes for custom commands isn't mentioned in the documents, but you asked for it to be implemented in the doubts doc.
Q18 . can we implement the write operation through naming server rather than storage server