Step 4 - Challenge: Commands With Arguments
Step 4 - Challenge: Commands With Arguments
Build Your Own Shell (Python Edition)
Step 1 - Create The Simplest Possible Command Line Shell
Step 1 - Create The Simplest Possible Command Line Shell
Step 2 - Challenge: Handle Multiple Commands
Step 2 - Challenge: Handle Multiple Commands
Step 3 - Non Existent Commands
Step 3 - Non Existent Commands
Step 4 - External Commands With Arguments
Step 4 - External Commands With Arguments
Step 7 - Handling Signals
Step 7 - Handling Signals
Conclusion
Conclusion
In this step your goal is to be able to run external commands that take arguments, for example ls -la, or cat <filename>.
To do that we’ll need to capture the user input and then split it into parts, the command and the arguments to be passed to the command that we spawn. For example, I’ll run my shell and pass a filename to the cat program, which prints out to the terminal the contents of the file:
% ccsh
ccsh> cat cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ccsh"
version = "0.1.0"
ccsh> exit
%