📄 readme
字号:
<help>myshell 1.0
Operating System ---- Project 1
Copyright@Yang Fuqiang
ID:01051312myshell supports the following internal commands:
cd clr dir echo environ
help myshell pause pwd quitAnd the executive external file can be executed too, just like external commnads.Type "help more" to see the whole user manual,or you can seek the help information as the following themes:"help command" ---see the internal commands;"help shell"---see more detail about this shell;"help help" ---see the usage of 'help' command;"help bat"---see how the shell execute from a batchfile;"help i/o redirection"---learn about the i/o redirection;"help background"---learn about the background mode; "help path"---see the format of filepath or dirpath.
#
<help shell>
The Shell or Command Line Interpreter is the fundamental user interface to an Operating System. The shell:
* interprets the input,
* takes appropriate action, and
* finally prompts for more input.
The shell can be used either
* as interactively - enter commands at the command prompt,
or
* as an interpreter to execute a shell script.
#
Code of myshell is writen in 'straight' C using the compiler of gcc. Myshell has been debugged in Ubuntu 7.10, and it can be implemented on the specifed UNIX platform. However, myshell is just a simple shell --- that has the following properties:
************************* Internal commands **********************
*********************************************************************
<help command> <help commands> <help internal command> <help internal commands>
myshell supports the following internal commands:
cd clr dir echo environ
help myshell pause pwd quit And the executive external file can be executed too.
Type "help [command]" to get the detail usage of each command.
e.g. help dir
#
<help bat> <help batchfile>
************************ Script file support *********************
*********************************************************************
myshell is able to take its command line input from a batchfile. i.e. if the shell is invoked with a command line argument:
e.g. myshell a.bat
then the batchfile -- a.bat -- is assumed to contain a set of command lines for the shell to process. When the end-of -file is reached, the shell should exit. Obviously, if the shell is invoked without a command line argument it solicits input from the user via a prompt on the display.
See also "help myshell".
#
<help i/o redirection> <help I/O Redirection> <help io redirection>
************************ I/O Redirection ***********************
******************************************************************
Some times when the arguments to a command is too many that you may waste a lot of time to type them from the keyboard. Fortunately, input redirection allows you to assign the arguments from a file. On the other hand, you can output the executoion results into a file instead of displaying them in screen. This is called output redirection. In a word, I/O Redirection allows you to use inputfile and outputfile to replace the standard input(keyboard) and standard output(screen) respectively.
myshell supports i/o-redirection on either or both stdin(standard input) and/or stdout(standard output). i.e. the command line:
e.g. programname arg1 arg2 <inputfile >outputfile
this will execute the program programname with arguments arg1 and arg2, the stdin FILE stream replaced by inputfile and the stdout FILE stream replaced by outputfile.
The file can be given by the full path as:
/home/username/a.txt
As to the file path format, type "help path" to get more information.
Input redirection --i.e. stdin redirection-- is possible for the internal commands: cd, dir, echo.
Output redirection --i.e. stdout redirection-- is possible for the internal commands: dir, environ, echo, help, pwd.
<help redirection>
* when the redirection token is < then the inputfile is opened if it exists, or a "Path Error" wil be reported in the screen. e.g. cd <a.txt
* when the redirection token is > then the outputfile is created if it does not exist and truncated if it does. e.g. ls >a.txt
* when the redirection token is >> then outputfile is created if it does not exist and appended to if it does. e.g. environ >>a.txtSometimes you can use more than one token to open several files as input or/and output. e.g. echo <m.txt >n.txt dir >m.txt >n.txt
If the file cannot opened due to read permission or write permission, an "Open Error" wil be reported in the screen.
#
<help background execution> <help background>
************************ Background Execution ******************
********************************************************************
Normally, when a command is execution, you have to wait for the completion and type another command. Especially, when the comand is executed from a batchfile, much time is wasted in waiting. Background execution allows you not to wait for the execution. An ampersand (&) at the end of the command line indicates that the shell should execute the command in background.
myshell supports background execution of programs. An ampersand (&) at the end of the command line indicates that the shell should return to the command line prompt immediately after launching that program.
#
******************* Detail usage of each command **************
*******************************************************************
<help cd>
Format: cd [directory]
-- change the current default directory to [directory].
e.g. cd /home
This command also change the PWD environment variable (use the command "pwd" to see it).
As to the directory path, type "help path" to get more information.
If the [directory] argument is not present, report the current directory.
If the directory does not exist, a "Path Error" wil be reported in the screen.
Moreover, you can use a directory path writen in a file as:
e.g. cd <a.txt
The file can be given by the full path as:
cd </home/username/a.txt
As to the file path format, type "help path" to get more information.
#
<help clr> <help clear>
Format: clr
or clear
-- clear the screen, no arguments is needed.
#
<help dir>
Format: dir [directory]
-- list the contents of directory [directory]
e.g. dir /home
This command is different from "cd", it change neither the current default directory nor the PWD environment variable(use the command "pwd" to see it).
As to the directory path, type "help path" to get more information.
If the [directory] argument is not present, list the contents of the current directory. If the directory does not exist, a "Path Error" wil be reported in the screen.
Moreover, you can use a directory path writen in a file as:
e.g. dir <a.txt
And you can list the contents into a file or more than one file as:
e.g. dir >b.txt or dir >b.txt >c.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
You can use both input redirection and output redirection as:
e.g. dir <a.txt >b.txt >c.txt
The file can be given by the full path as:
dir </home/username/a.txt
As to the file path format, type "help path" to get more information.
#
<help environ>
Format: environ
-- list all the environment strings in screen or into one file or more than one file as:
e.g. envieron or environ >b.txt or environ >b.txt >c.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
The file can be given by the full path as:
/home/a.txt
As to the file path format, type "help path" to get more information.
#
<help echo>
Format: echo [comment]
-- display [comment] on the display or output files followed by a new line. And multiple spaces/tabs will be reduced to a single space.
e.g. echo hello world
The words "hello world" will display in the screen.
[comment] can be multiple words either typed from keyboard or read from one or more input files.
e.g. echo <a.txt or echo <a.txt <b.txt
And you can display or output the contents into one file or more than one file:
e.g. echo hello world >c.txt or echo hello world >c.txt >d.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
You can use both input redirection and output redirection:
e.g. echo <a.txt <b.txt >c.txt >d.txt
The file can be given by the full path as:
echo </home/a.txt >/home/b.txt
As to the file path format, type "help path" to get more information.
#
<help help>
Format: help or ?
-- display the user manual. Type "help [command]" to get the detail usage of a command as:
e.g. help dir or ? dir
Type "help command" to see the internal commands.
And you can display or output the help information into one file or more than one file as:
e.g. help dir >c.txt or help dir >c.txt >d.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
The file can be given by the full path as:
help dir >/home/a.txt
As to the file path format, type "help path" to get more information.
#
<help myshell>
Format: myshell batchfile
or myshell <batchfile
-- keep reading a line of command from batchfile and execute.
e.g. myshell a.bat or myshell <a.bat
where a.bat is a batchfile contains many lines of commands.
You can display or output the execution results into one file or more than one file as:
e.g. myshell a.bat >c.txt or myshell a.bat >c.txt >d.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
The file can be given by the full path as:
e.g. myshell </home/a.txt >/home/username/b.txt
As to the file path format, type "help path" to get more information.then put results in outputfile.
#
<help pause>
Format: pause
-- display "Press Enter to continue..." and pause operation of the shell until the 'Enter' key is pressed (ignore any intervening non-'Enter' input).
#
<help pwd>
Format: pwd
-- show the PWD environment variable. If you want to list all the environment strings, use command "environ", type "help environ" to see.
You can display or output the execution results into one file or more than one file as:
e.g. pwd a.bat >c.txt or pwd a.bat >c.txt >d.txt
The token ">" can be replaced by ">>", type "help redirection" to see the difference of ">" and ">>".
The file can be given by the full path as:
e.g. pwd >/home/a.txt
As to the file path format, type "help path" to get more information.then put results in outputfile.
#
<help quit> <help exit>
Format: quit or exit
-- Exit myshell, no argument is needed.
#
<help path> <help ..> <help .> <help ~>
********************* Directory path and File path******************
*************************************************************************
.. . and ~ can be used in pathnames.
.. stands for the parent directory of the current working directory,
. stands for the current working directory,
~ stands for the home directory.If the filename or directoryname contains a white space, type "\ " : e.g. echo <a\ b ( display the contents of file "a b" )
Besides, there cannot be a white space in the path, or else a "Path Error" wil be reported in the screen.
#
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -