What happens when you type ls -l in the shell

Program Specifications

Basic Shell

Built-in Commands

[optionalSpace]exit[optionalSpace]
[optionalSpace]pwd[optionalSpace]
[optionalSpace]cd[optionalSpace]
[optionalSpace]cd[oneOrMoreSpace]dir[optionalSpace]
[optionalSpace]wait[optionalSpace]
% cd
% pwd
/afs/cs.wisc.edu/u/m/j/username
% echo $PWD
/u/m/j/username
% ./mysh
mysh> pwd
/afs/cs.wisc.edu/u/m/j/username

Redirection

ls > out1 out2
ls > out1 out2 out3
ls > out1 > out2

Background Jobs

mysh> ls &
mysh> ls &
mysh> ps &
mysh> find . -name *.c -print &
mysh> ls &
mysh> ps &
mysh> find . -name *.c -print &
mysh> wait

Fun Feature

prompt> hello.py

Program Errors

char error_message[30] = "An error has occurred\n";
write(STDERR_FILENO, error_message, strlen(error_message));

White Spaces

mysh> ls
mysh> ls > a
mysh> ls>a

Batch Mode

write(STDOUT_FILENO, cmdline, strlen(cmdline));
emperor1% ./mysh
mysh> ls
some output printed here
mysh> ls > /tmp/ls-out
some output printed here
mysh> notACommand
some error printed here
ls
ls > /tmp/ls-out
notACommand
prompt> ./mysh myBatchFile
ls
some output printed here
ls > /tmp/ls-out
some output printed here
notACommand
some error printed here

Defensive Programming and Error Messages

char error_message[30] = "An error has occurred\n";
write(STDERR_FILENO, error_message, strlen(error_message));

Hints

Basic Shell

Built-in Commands

Redirection

Miscellaneous Hints

Handin

emperor1% ./mysh
emperor1% ./mysh inputTestFile

Grading

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Install a Subsonic Media Streamer on Alibaba Cloud

#NoEstimates: 6 Software Experts Give Their View on the Movement

VM Failover Guide

Java 8 | Nested Loop Practice — Multiplication Table

MicroChains Weekly Technical Update # 9(June 20th-26th, 2022)

Synchronous vs. Asynchronous Replication Strategy

Two Way Data Binding

S3 delete objects older certain modified date(boto3)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Leopoldo Luna

Leopoldo Luna

More from Medium

How I am rapidly executing a burnout recovery plan… I Am Officially Burnt Out To The Max

My 1:1 with Nikesh Arora

Platform of progress in the future,

Summary and Opinion paragraph: TV