MIT CSCI202 Lab 2 - Shell


  • 作业标题:Lab 2: Shell
  • 课程名称:MIT CSCI202
  • 完成周期:3天

Introduction

The shell is the main command-line interface between a user and the
operating system, and it is an essential part of the daily lives of computer
scientists, software engineers, system administrators, and such. It makes
heavy use of many OS features. In this lab, you will build a simpliØed
version of the Unix shell called the New Yet Usable SHell, or nyush for
short.

Please review the first lecture of MIT’s The Missing Semester of Your CS
Education if you are not familiar with the shell.

Objectives

Through this lab, you will:

  • Familiarize yourself with the Linux programming environment andthe shell, of course.
  • Learn how to write an interactive command-line program.
  • Learn how processes are created, destroyed, and managed.
  • Learn how to handle signals and I/O redirection.
  • Get a better understanding of the OS and system calls.
  • Be a better C programmer and be better prepared for your future technical job interviews. In particular, the string parsing skill that you will practice in this lab is desired in many interview questions.

Overview

The shell is essentially a command-line interpreter. It works as follows:

  1. It prompts you to enter a command.
  2. It interprets the command you entered.
    • If you entered a built-in command (e.g., cd ), then the shell runs that command.
    • If you entered an external program (e.g., /bin/ls ), or multiple
      programs connected through pipes (e.g., ls -l | less ), then the
      shell creates child processes, executes these programs, and waits
      for all these processes to either terminate or be suspended.
    • If you entered something wrong, then the shell prints an error message.
  3. Rinse and repeat until you press Ctrl-D to close STDIN or enter the
    built-in command exit , at which point the shell exits

Specizcations

Your shell should follow these speciØcations carefully. These
specifications may be slight different from the default Linux shell ( bash )
for simplicity.

The prompt

The prompt is what the shell prints before waiting for you to enter a
command. In this lab, your prompt must have exactly the following
format:

…omit…

Tips

Don’t procrastinate! Don’t procrastinate!! Don’t
procrastinate!!!

This lab is significantly more challenging than Lab 1 and requires
significant programming effort. Therefore, start as early as possible!

Don’t wait until the last week.

How to get started?

Please review our academic integrity policy carefully before you start.
This lab requires you to write a complete system from scratch, so it may
be daunting at Ørst. Remember to get the basic functionality working
Ørst, and build up your shell step-by-step.


文章作者: IT神助攻
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 IT神助攻 !
  目录