首页 > 系统相关 >COMP2211A small shell interface

COMP2211A small shell interface

时间:2024-11-08 20:58:46浏览次数:1  
标签:commands shell should will COMP2211A command small xv6

Chapter 5

Week 4: Creating a small shell interface You must submit your work to the appropriate submission point in Gradescope, which willbe automatically marked. You should submit a single file called my_shell.c. Any otherfiles you submit will not be marked. Although you do not need to include any additionalsupporting documentation or report, we do expect that yourcode is well written, tested andcommented.

Deadline: Week 6 of teaching. Thursday. 7th of Novem

ber, 2024. 14:00. Extensions of up to 7 days are available.

Weighting: 40% of the final module mark.In this coursework you will demonstrate:

  • An understanding of how processes are created by the operating system.
  • An understanding of file descriptors and their relationship to pipes and redirection.
  • The ability to program components of an operating system.

Exercise

In this coursework you will implement a simple shell for the xv6 operating system. Thisnew shell will be implemented as a user space program. Before you attempt this coursework,make sure you have gone through most of the formative assessment exercises in the precedingweeks and convinced yourself that you know how various parts work. Where you have doubts,read relevant parts again and redo the coursework, which will make you spot new things andgain a deeper understanding of the material. You should provide your implementation in anew file called my_shell.c. You may use any helper functions provided by the xv6 kernel oruser libraries. For each of the following items implement the feature into your shell, as youprogress the features to implement become harder. This exercise should not require you tomodify any file other than my_shell.c and the Makefile.To start with clone the repository containing the starting code and copy my_shell.cfrom it into your xv6 user/ directory:29$ git clone https://github.com/mmikaitis/COMP2211-shell-template.gitModify the Makefile accordingly and rebuild xv6. It will not compile because my_shell.c isnot finalised yet. However, it also contains some commentsthat should help in finishing thentended structure. Your task is to finish writing methods getcmd, run_command, and main,by inserting code in the indicated locations. No other methods should be developed.You are allowed to look at a default xv6 shell source code as well aslearn about implementing shells using external resources. However,you are required to follow the unique structure outlined in the template and are not allowed to supply any code which was not developedsolely by yourself, starting from design stage. If you depend highlyon some online tutorials then you need to declare the sources in thecomments, which includes large language models. If you discuss earlyideas with someone in the lab you should make sure that you don’tend up with similar code structure; you should not code together.Gradescope willrun a similarity check of your submission and if thelogic of the new code is reported to be similar to someone else’s,the submission will be carefully checked manually and reported asacademic integrity violation if required. See this website for somedetail. The similarity check is resilient to changing variables namesor adding comments and new lines.Going through academic integrity interviews is a daunting process andmay result in severe delays to your degree progression. It is betterto submit nothing than submit the code that was partially developedby others. Ifyou are behind, speak to the lab demonstrators and themodule lead for guidance on best ways forward.

Part 1: Execute simple commands (5 Marks) Implement the execution of simple commands. Your shell should be able to:

  • Prompt the user for a command by printing “>>>” as a command prompt.
  • Execute a command inputted to the command prompt.
  • Loop indefinitely until the shell is exited.
  • Handle the “cd” command—you will notice that this command will need to be treatedas a special case.Do not forget to stress-test your simple shell before moving on to advanced features. Theautomatic marking will be testing it on various cases and marks will be deducted if it doesnot work when the same command is provided in a different format, such as with extra30spacing. For example, consider (note the amountandlocation of space characters whichmay 代写COMP2211A small shell interface  impact the shell if they are not detected):

$ echo hello world

$ echo hello worldOnce you are comfortable that you have tested your shell with any possible command thatcould reveal bugs, move on to implement the following advanced features.

Part 2: Input/Output redirection (6 Marks)

Implement Input/Output redirection. Your shell should be able to handle two elementedirections. For example,

$ echo "Hello world" > temp

$ cat < temp

Part 3: Pipes (6 Marks) Implement pipes. Your shell should be able to handle two element pipelines. For example,

$ cat README | grep github

Part 4: Additional features (8 Marks) Implement the following advanced features:

  1. Implement multi-element pipelines. For example,$ ls | grep test | cat
  1. Implement non-trivial combinations of pipes and redirection. For example,$ ls | grep test | cat > myoutput
  1. Implement the “;” operator that allows a list of shell commands to be given andexecuted sequentially.$ ls | grep test | cat > myoutput; cat myoutput

Marking

Gradescope will run 26 test commands and award a mark out of 25. The commands that willbe run are not disclosed and you are required to usecreativity to think of various scenarioswhich may break your shell and test it thoroughly before submitting. 3 out of 25 marks31will be awarded to those who spot three especially tricky cases of specifying commands andimplement their shells to get around them.There are many ways to type commands, some straightforward as shown above, andsome not, such as when people type commands without usingany spaces or with arbitrary

number of spaces in various places. Your shell should be resilient to this ambiguity inspecifying commands. Those students who spent more time inthinking about various testcases and check them will get more marks than those who only try a few straightforwardcommands listed above.Here are a few example commands running in the new completed shell to get you started:xv6 kernel is booting

hart 2 starting

hart 1 starting

init: starting sh

>>> echo hellohello

>>> cat README | grep xv6xv6 is a re-implementation of Dennis Ritchie’s and Ken Thompson’s Unix

Version 6 (v6). xv6 loosely follows the structure and style of v6,xv6 is inspired by John Lions’s Commentary on UNIX 6th Edition (Peer

(kaashoek,[email protected]). The main purpose of xv6 is as a teaching>>> cat README| grep xv6xv6 is a re-implementation of Dennis Ritchie’s and Ken Thompson’s UnixVersion 6 (v6). xv6 loosely follows the structure and style of v6,xv6 is inspired by John Lions’s Commentary on UNIX 6th Edition (Peer(kaashoek,[email protected]). The main purpose of xv6 is as a teaching

>>>

It is worth to note that the default xv6 does not pass all of our expected tests. Fort only my_shell.c. See Minerva.34

标签:commands,shell,should,will,COMP2211A,command,small,xv6
From: https://www.cnblogs.com/comp9321/p/18535301

相关文章

  • 第二周学习笔记Linux:Linux用户权限管理 |文本处理|shell基础
    用户权限命令以及ACL权限相关命令1.Linux安全模型资源分派:Authenticaton:登陆认证,验证用户身份Authorization:授权,不同的用户设置不同权限Accouting:审计,检查用户的时候行为即Linux的AAA认证,是针对网络设备的网络访问控制策略和安全模型1用户Linux是多系统用户,可以......
  • Shell概述、编写及执行脚本、Shell变量+数值运算
    一、shell基本介绍 1.1 什么是shell◆ 在Linux内核与用户之间的解释器程序◆通常指/bin/bash◆负责向内核翻译及传达用户/程序指令◆相当于操作系统的“外壳”1.2 shell使用方式◆交互式 ——命令行-----人工干预、智能化程度高-----逐条解释执行、效率......
  • 监控 Windows 更新补丁安装过程中的文件夹和文件,可以通过 PowerShell 监控 Windows 更
    监控Windows更新补丁安装过程中的文件夹和文件,可以通过PowerShell监控Windows更新的日志文件夹、注册表或其他相关位置。Windows更新会在多个地方生成日志和文件,下面提供了一个使用PowerShell监控Windows更新相关路径、文件夹及文件的示例。监控Windows更新相关的文......
  • c++执行shell操作
     message("----->>>>>shelldemo/CMakeLists.txt")#收集当前目录下所有的.cpp文件aux_source_directory(.DIR_SRCS)#添加可执行文件add_executable(shelldemo${DIR_SRCS})#链接需要的库target_link_libraries(shelldemo${LIB_LIB})/shelldemo/CMakeList......
  • 命令行工具PowerShell使用体验
    命令行工具PowerShell使用PowerShell是微软开发的一种面向对象的命令行Shell和脚本语言环境,它允许用户通过命令行的方式管理操作系统。相较于传统CMD,PowerShell增加了面向对象的程序设计框架,拥有更强大的功能和扩展性。使用PowerShell可以方便地自动化系统管理任务,构建脚本......
  • dotnet cli publish 命令行发布脚本 bat shell
    dotnetcli发布脚本publish_remote.bat该脚本实现一键主要发布到远程的共享文件夹中@echooff::定义变量SHARE_PATH:共享文件夹,SOURCE_DIR:代码发布的文件夹,TARGET_DIR:目标文件夹(共享文件夹的映射)setPRO_PATH=.\WebAppsetSHARE_PATH=\\pcmesone\Reportset......
  • PowerShell DSC(Desired State Configuration)是一种配置管理框架,旨在通过声明性的方式
    PowerShellDSC(DesiredStateConfiguration)是一种配置管理框架,旨在通过声明性的方式自动化和管理计算机的配置。它是WindowsPowerShell的一部分,允许管理员定义和维护计算机系统的目标配置状态,而不是手动进行逐个更改。1. 什么是PowerShellDSC?PowerShellDSC是一种基于声......
  • PowerShell 脚本(.ps1)、批处理文件(.bat)、VBScript(.vbs) 和 旧版 JavaScript(.js) 都可以在
    PowerShell脚本(.ps1)、批处理文件(.bat)、VBScript(.vbs)和旧版JavaScript(.js)都可以在Windows系统中运行,但它们的兼容性和支持范围有一定的差异,尤其是在不同的Windows版本上。下面是它们在Windows系统中支持的情况:1. PowerShell脚本(.ps1)兼容性: PowerShell是自Window......
  • Xshell 8 Build 0063绿色特别版发布:功能强大且永久免费使用
    软件介绍Xshell是一款功能强大的Linux远程连接工具,被誉为SSH终端管理器和SSH远程连接主机客户端的最佳选择。它不仅支持多选项卡管理多个主机,还提供了对多种远程协议的支持,如Telnet、Rlogin、SSH/SSHPKCS#11、SFTP和Serial等。此外,Xshell还具备Unicode编码支持、动态端口转发、自......
  • shell脚本入门——流程控制方法和代码
    Shell脚本是一种用于自动化任务和管理系统的强大工具。在编写Shell脚本时,流程控制(如条件判断、循环等)是最基础也是最重要的部分之一。以下是一些常用的Shell流程控制结构:1.条件判断(if语句)Shell脚本中的if语句用于根据条件判断执行不同的代码块。#!/bin/bash#判断文件......