2019 Spring, CSCI 3150 – Assignment 1Deadline: April 25, 2019 11:00AMContents1 Change Log 32 Introduction 32.1 Execution of any Linux program . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Shell-specific commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2.1 gofolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2.2 push,pop and dirs . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.3 bye . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Basic signal handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.4 Basic command chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 The Assignment Package 84 Your assignment 84.1 To begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Submitting your assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015 Assumptions 106 Grading 107 Questions 118 Academic Honesty 129 General Notes 1221 Change Log1.0 This version2 IntroductionIn this assignment, you are going to implement a mini-shell, namely, asg1-shell, using C.If one invokes the program asg1-shell, we shall see something like this:Figure 1: Your shellThe prompt has the format of [3150 Shell:]=>. Your shell shallsupport: Execution of any Linux built-in command (e.g., ls). Five shell-specific commands: gofolder, push, pop, dirs and bye. Basic signal handling: i.e., a user cannot exit the shell simply by typing ctrl-c.Basic command chaining: && and k. Basic error handling.2.1 Execution of any Linux programYour shell shall allow a user to execute any Linux program, with basic error handling. Notethat the user can input either an absolute path (e.g., /bin/ls) or just a filename (e.g.,ls). If an absolute path is not given, your shell should search the program in the followingsequence:3/bin → /usr/bin → . (current directory)In case your shell cannot locate the program, your shell should report an error message“{command name}: command not found” (see Figure below).*2.2 Shell-specific commands2.2.1 gofolderThis command is similar to cd command in Linux, for changing the working directory, likebelow:4After a successful operation, your prompt shall be updated with current directory name.Please note that you are just required to implement basic changing of directory as shownabove.2.2.2 push,pop and dirsThese commands behave similarly to Linux commands pushd, popd, and dirs. On push [directory path], the shell shall (1) push the current directory to a stack,(2) change to the directory specified by [directory path], and (3) print the contentof the stack. On dirs, the shell shall print the content of the stack. The format is:[item number] [path]With the most recent item starts with item number 0 and the oldest item in the stackhas the largest item number. On pop, the shell shall (1) pop an item from the stack, (2) change to that directoryand (3) print the content of the stack.If the end of the stack is reached, the shell should prompt the user:pop: directory stack emptyExample:52.2.3 byeThis command is equivalent to exit command in Linux, which lets a user to terminate theshell (and back to the normal Linux bash shell).2.3 Basic signal handlingYour shell shall handle the following list of signals as follow:Signal ActionSIGINT (Ctrl + C) Ignore the signal.SIGTERM (default signal of command “kill”) Ignore the signal.SIGQUIT (Ctrl + ) Ignore the signal.SIGTSTP (Ctrl + Z) Ignore the signal.62.4 Basic command chainingYour shell should handle two logical operations: AND(&&) and OR(k), like below:73 The Assignment PackageYou should have opened a Github account and told us your github account by filling up aGoogle form during your assignment 0. So, after logging in your Github account, come herehttps://classroom.github.com/a/KKQgMaHn to get a new repo for this assignment. Thenew repo should contain the starter package for this assignment.4 Your assignmentYou are given the following files:Name Description/asg1-shell.c Source code of a runnable but non-functioning shell(Work on it)./asg1-shell Executable of a runnable but non-functioning shell.(Try to run it; Type ctrl-d to quit)/demo-asg1 Executable, serve as the demo of what you shallimplement. Our grading will also use this to definetest cases. That is, the behavior of your shell shallexactly follow this demo./hello Executable, a hello world program./testcases/data Test data./Makefile Makefile to compile asg1-shell./grader.sh We will run this script to grade your assignment(Don’t touch).84.1 To beginMake, then run grader.sh, you shall see something like this:This shell script feeds in some test cases to asg1-shell (barely functioning, but youshould make it functioning in this assignment) and demo-asg1 (which is functioning, but nosource code is given) to match their outputs, and reports the number of test cases passed.Initially, it shall report that none of the test cases passes. Your job is to make all test casespass:If you invoke the grader script like the following:./grader.sh 2Then it only runs test case 2 for you.94.2 Submitting your assignmentFollow the procedure in assignment 0.5 AssumptionsYou can assume the following always holds in this assignment:Input An input command line has a maximum length of 255 characters, including the trailingnewline character. An input command line ends with a new line character There would be no leading or trailing space characters in the input command line. A token is a series of characters without any space character. Each token is separatedby exactly one space character only.? There will be no combination of shell commands in command chaining. For example,no test cases like ls || bye, bye && bye, bye || ls are defined. Your shell should also be terminated by ‘Ctrl-D’, the end-of-file character (NOT signal)upon receiving in the prompt.6 Grading1. The TA will fetch and grade your latest version in your repo as of April 25, 2019,11:00AM. Remember to commit and push before the deadline.2. Your shell shall output results to standard output stream (stdout). Otherwise, youwill get 0 mark.3. The objective of this assignment is to let you practice the necessary system programmingskills. So you are not allowed to do your assignment in a way that violates that10objective. Therefore, you cannot invoke system(3) library call, invoke any existingshell programs, including but not limited to: “/bin/sh”, “/bin/bash”, “pushd”, callingnon built-in linux libraries and etc. Otherwise, you will score 0 mark. If you havedoubts about the legitimacy of your program, you may ask on Piazza.4. Your shell should not leave any zombies in the system when it is ready to accept a newuser input. Otherwise, you will have 1 test case marks deducted.5. There are 30 test cases in total. Test case 6 and test case 24 carry more weight – eachcarries 6.25 mark. Each of the rest carries 3.125 mark.6. Maximum assignment score is 100.7. FAQ: Why the grader says a test case fails even if I test my shell under a terminalwithout any problem?Answer: This error usually appears if you forget to handle some error cases. In thefigure below, you can see a command ‘command not exists’ was fed to your shell.This is a wrong command, therefore your shell cannot execute that and return tothe command prompt. One common case is that the child that handles the wrongcommand still exists as exec*() fails. Therefore it is the child prompting you forinput instead of the parent. As the result, you need to bye twice in order to return tothe Linux shell. In this scenario, the grader will report a failed test case.7 QuestionsIf you have doubts about the assignment, you are encouraged to ask questions on Piazzausing the corresponding tag. Please focus on knowledge. Unhealthy questions/comments11that focus on scores and grades are not encouraged.If you find any (possible) bugs, send private questions on Piazza to us instead— otherwise that may cause unnecessary panic among the class if that is not a real bug.8 Academic HonestyWe follow the University guide on academic honesty against any plagiarism.9 General Notes This specification and our grading platform are both based our given course VM. Youshould compile, debug and run the assignment program on that VM. So, if you insistto develop on another platform other than our VM and got any question, test it onour VM before you ask. The TA reserves the right to adjust your scores for any request that requires their extramanual effort. Unless specified, you should work and fill your code in designated areas. There arecases that the modification outside the designated area leads to misbehavior of the autograder. Proceed with caution and look back the changes if your output is different fromwhat is shown in the grader. While we have already tried our best to prepare this assignment, we reserve all therights to update the specification and the grading scheme. If there are any mistakes/bugswhich are on ours, the TA will step in and do manual grading to ensureyou get what you deserve. Please respect each other. Any irresponsible, unfair, biasedsentiment would regard as a disciplinary case. If this is a programming assignment, only C is allowed, not even C++. If this is ascripting assignment, only bash shell script is allowed, not even Python. Furthermore,for C programming assignments, use the “exit” function parsimoniously because itmight influence the grader as well. Therefore, use “return” instead of “exit” wheneverpossible.12 Although this is not an algorithm class, you still shouldn’t implement your assignmentwith very poor complexity. While the TAs will try their best to run your programas long as they could, they reserve the right to terminate a test case and regard thatas a failed test case when a program takes unreasonably long time to finish (try tocompare your running time with the TA’s demo if it is given), or until when the TAscan’t run any longer due to the deadline the TA needs to submit your final scores tothe department. When grading, the TAs will execute the grader program to run the whole test suite(which consists of all test cases). The TAs won’t grade each individual test caseseparately. (Frequently Asked) [Output format] If the assignment package includes a demo,then our grader defines test cases based on the given demo. In that case, your outputshall exactly follow that demo. For example, hypothetically, if our demo outputs amessage like:command not foundwith two spaces between “not” and “found”. Your output shall also match that inorder to pass the test. The good news is that, if our given demo has not implementedsomething (e.g., missed certain error checking), you also don’t need to do so. Notest cases would be defined based on something that our demo has notimplemented. (Frequently Asked) [Scope of error handling] The scope of error checking andhandling shall refer to both our given demo (if given) and our given test cases.First, the corresponding output message shall exactly follow our demo. Second, youare informed that our demo may have implemented more error checking that what ourgrader will test. In that case, it is fine that you implement only the error checking thatis tested by our grader. So, one top tip is:CHECK THE (SOURCE OF)13TEST CASES BEFORE YOU ASK (Frequently Asked) [No hidden test case] We are not intended to run any secret/extratest cases that deliberately break your assignment. That is, WYSIWYG — yourfinal score shall be generally indicated by what the grader reports when it runs onthe course VM. However, we do reserve the right to run some additional test cases toavoid any mis-conduct (e.g., hard-coding the results), and/or invite you to explain thesource code to the teaching assistants and adjust the scores accordingly. We welcome discussions among classmates. But don’t share your assignment with theothers in any means. For example, don’t put your source code in any public venue (e.g,public repo, your homepage, Facebook). We handle plagiarism strictly. On submittingthis assignment, you are agreed that your code’s copyright belongs to the ChineseUniversity of Hong Kong. Unless with our written approval, you must not releaseyour source code and this specification now and forever. If you share your code withanyone without our written consent, that would regard as a disciplinary case as longas you are still a CUHK student (i.e., even after this course). If you share your codewith anyone without our written consent after your graduation, that would regard asa breach of copyright and we reserve all the rights to take the corresponding legalactions. Google is your friend. We encourage you use Google for help to do the assignment.However, if you happen to find any source codes related to this assignment, you stillcannot copy it but use your own way to implement it. You need to put down your listof source code references as comments in the top of your source code. (Frequently Asked) [Late Policy] TAs will only grade the latest version submittedbefore the deadline, no late submission is allowed. It is your responsibility to makesure you added, committed, and pushed the final version before the deadline. You arerequired to check whether your final version is really in Github Classroom.14本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp
网友评论