csh.1
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1 代码 · 共 2,332 行 · 第 1/5 页
1
2,332 行
TERM into.I term,andHOME into.I home,and copies these back into the environment whenever the normalshell variables are reset.The environment variable PATH is likewise handled. It is notnecessary to worry about its setting other than in the file.PN \&.cshrcas inferior.PN cshprocesses will import the definition of.I pathfrom the environment, and re-export it if you then change it..TP 15.B argv\cSet to the arguments to the shell, it is from this variable thatpositional parameters are substituted, that is `$1' is replaced by`$argv[1]', and so forth..TP 15.B cdpath\cGives a list of alternate directories searched to find subdirectoriesin.I chdircommands..TP 15.B cwdThe full pathname of the current directory..TP 15.B echo\cSet when the.B \-xcommand line option is given.Causes each command and its argumentsto be echoed just before it is executed.For non-built-in commands all expansions occur before echoing.Built-in commands are echoed before command and file name substitution,since these substitutions are then done selectively..TP 15.B histchars\cCan be given a string value to change the characters used in historysubstitution. The first character of its value is used as thehistory substitution character, replacing the default character !.The second character of its value replaces the character ! inquick substitutions..TP 15.B history\cCan be given a numeric value to control the size of the history list.Any command which has been referenced in this many events will not bediscarded.Too large values of.I historymay run the shell out of memory.The last executed command is always saved on the history list..TP 15.B home\cThe home directory of the invoker, initialized from the environment.The file name expansion of `\fB~\fR' refers to this variable..TP 15.B ignoreeof\cIf set the shell ignoresend-of-file from input devices which are terminals.This prevents shells from accidentally being killed by control-D's..TP 15.B mail\cThe files where the shell checks for mail.This is done after each command completion which will result in a prompt,if a specified interval has elapsed.The shell says `You have new mail.'if the file exists with an access time not greater than its modify time..IPIf the first word of the value of.I mailis numeric it specifies a different mail checking interval, in seconds,than the default, which is 10 minutes..IPIf multiple mail files are specified, then the shell says`New mail in.IR name 'when there is mail in the file.I name..TP 15.B noclobber\cAs described in the section on.I Input/output,restrictions are placed on output redirection to insure thatfiles are not accidentally destroyed, and that `>>' redirectionsrefer to existing files..TP 15.B noglob\cIf set, file name expansion is inhibited.This is most useful in shell scripts which are not dealing with file names,or after a list of file names has been obtained and further expansionsare not desirable..TP 15.B nonomatch\cIf set, it is not an error for a file name expansion to not match anyexisting files; rather the primitive pattern is returned.It is still an error for the primitive pattern to be malformed, that is`echo [' still gives an error..TP 15.B notify\cIf set, the shell notifies asynchronously of job completions. Thedefault is to rather present job completions just before printinga prompt..TP 15.B path\cEach word of the path variable specifies a directory in whichcommands are to be sought for execution.A null word specifies the current directory.If there is no.I pathvariable then only full path names will execute.The usual search path is `.', `/bin' and `/usr/bin', but thismay vary from system to system.For the super-user the default search path is `/etc', `/bin' and `/usr/bin'.A shell which is given neither the.B \-cnor the.B \-toption will normally hash the contents of the directories in the.I pathvariable after reading.PN \&.cshrc ,and each time the.I pathvariable is reset. If new commands are added to these directorieswhile the shell is active, it may be necessary to give the.I rehashor the commands may not be found..TP 15.B prompt\cThe string which is printed before each command is read froman interactive terminal input.If a `!' appears in the string it will be replaced by the current event numberunless a preceding `\e' is given.Default is `% ', or `# ' for the super-user..TP 15.B savehist\cis given a numeric value to control the number of entries of thehistory list that are saved in ~/.history when the user logs out.Any command which has been referenced in this many events will be saved.During start up the shell sources ~/.history into the history listenabling history to be saved across logins.Too large values of.I savehistwill slow down the shell during start up..TP 15.B shell\cThe file in which the shell resides.This is used in forking shells to interpret files which have executebits set, but which are not executable by the system.(See the description of.I "Non-built-in Command Execution"below.)Initialized to the (system-dependent) home of the shell..TP 15.B status\cThe status returned by the last command.If it terminated abnormally, then 0200 is added to the status.Built-in commands which fail return exit status `1',all other built-in commands set status `0'..TP 15.B time\cControls automatic timing of commands.If set, then any command which takes more than this many cpu secondswill cause a line giving user, system, and real times and a utilizationpercentage which is the ratio of user plus system times to real timeto be printed when it terminates.The .B timecommand can be used to cause a command to be timed no matter how much CPU time it takes. Thus.EX% time cp /etc/rc /usr/bill/rc0.0u 0.1s 0:01 8% 2+1k 3+2io 1pf+0w% time wc /etc/rc /usr/bill/rc 52 178 1347 /etc/rc 52 178 1347 /usr/bill/rc 104 356 2694 total0.1u 0.1s 0:00 13% 3+3k 5+3io 7pf+0w%.EEThe preceding example indicates that the .I cp command used a negligible amount of user time (u) and about 1/10th of a second system time (s); the elapsed time was 1 second (0:01), there was an averagememory usage of 2k bytes of program space and 1k bytes of data space over the cputime involved (2+1k); the program did three disk reads and two disk writes (3+2io),and took one page fault and was not swapped (1pf+0w). The word count command.PN wcon the other hand used 0.1 seconds of user time and 0.1 seconds of system time inless than a second of elapsed time. The percentage `13%' indicates that over theperiod when it was active the command `wc' used an average of 13 percent of theavailable CPU cycles of the machine. .TP 15.B verbose\cSet by the.B \-vcommand line option, causes the words of each command to be printedafter history substitution..SH Non-built-in Command Execution.NXR "csh command interpreter" "non-built-in commands"When a command to be executed is found to not be a built-in commandthe shell attempts to execute the command via.MS execve 2 .Each word in the variable.I pathnames a directory from which the shell will attempt to execute the command.If it is given neither a.B \-cnor a.B \-toption, the shell will hash the names in these directories into an internaltable so that it will only try an.I execin a directory if there is a possibility that the command resides there.This greatly speeds command location when a large number of directoriesare present in the search path.If this mechanism has been turned off (via.IR unhash ),or if the shell was given a.B \-cor.B \-targument, and in any case for each directory component of.I pathwhich does not begin with a `/',the shell concatenates with the given command name to form a path nameof a file which it then attempts to execute..PPParenthesized commands are always executed in a subshell.Thus `(cd ; pwd) ; pwd' prints the.I homedirectory; leaving you where you were (printing this after the home directory),while `cd ; pwd' leaves you in the.I homedirectory.Parenthesized commands are most often used to prevent.I chdirfrom affecting the current shell..PPIf the file has execute permissions but is not anexecutable binary to the system, then it is assumed to be afile containing shell commands and a new shell is spawned to read it..PPIf there is an.I aliasfor.I shellthen the words of the alias will be prepended to the argument list to formthe shell command.The first word of the.I aliasshould be the full path name of the shell(for example, `$shell').Note that this is a special, late occurring, case of.I aliassubstitution,and only allows words to be prepended to the argument list without modification..SH Argument List Processing.NXR "csh command interpreter" "argument list processing"If argument 0 to the shell is `\-' then thisis a login shell.The flag arguments are interpreted as follows:.TP 5.B \-c\cThe first argument word is taken to be a command string.All remaining argument words are placed in.I argv..TP 5.B \-e\cThe shell exits if any invoked command terminates abnormallyor yields a non-zero exit status..TP 5.B \-f\cThe shell will start faster, because it will neither search for norexecute commands from the file`\&.cshrc' in the invokers home directory..TP 5.B \-i\cThe shell is interactive and prompts for its top-level input,even if stdin appears not to be a terminal.Shells are interactive without this option if their inputsand outputs are terminals..TP 5.B \-n\cCommands are parsed, but not executed.This aids in syntactic checking of shell scripts..TP 5.B \-s\cCommand input is taken from the standard input..TP 5.B \-t\cA single line of input is read and executed.A `\e' may be used to escape the new line at the end of thisline and continue onto another line..TP 5.B \-v\cCauses the.I verbosevariable to be set, with the effectthat command input is echoed after history substitution..TP 5.B \-x\cCauses the .I echovariable to be set, so that commands are echoed immediately before execution..TP 5.B \-V\cCauses the.I verbosevariable to be set even before `\&.cshrc' is executed..TP 5.B \-XCauses the echo variable to be set before `\&.cshrc' isexecuted..PPAfter processing of flag arguments if arguments remain but none of the.B \-c,.B \-i,.B \-s,or.B \-toptions was given the first argument is taken as the name of a file ofcommands to be executed.The shell opens this file, and saves its name for possible resubstitutionby `$0'.Since many systems use either the standard version 6 or version 7 shellswhose shell scripts are not compatible with this shell, the shell willexecute such a `standard' shell if the first character of a scriptis not a `#', that is if the script does not start with a comment.Remaining arguments initialize the variable.I argv..SH Signal Handling.NXR "csh command interpreter" "signal handling"The shell normally ignores.I quitsignals.Jobs running detached (either by `&' or the \fIbg\fR or \fB%... &\fRcommands) are immune to signals generated from the keyboard, includinghangups.Other signals have the values which the shell inherited from its parent.The shells handling of interrupts and terminate signalsin shell scripts can be controlled by.I onintr.Login shells catch the.I terminatesignal; otherwise this signal is passed on to children from the state in theshell's parent.In no case are interrupts allowed when a login shell is reading the file`\&.logout'..SH Command And Filename RecognitionThe.PN cshcommand recognizes and completes user name aliases, commands (includingbuilt-in.PN cshcommands), and filenames. To use this feature, do the following:.TP 31.Type enough characters at the prompt to make your input tothe system unique..TP2. Press the ESC key..PPIf your input is unique, the Shell completes the input line. If theinput is not unique, the terminal signals you with a beep. If youreceive a beep, type CTRL/D for a list of options. You can thentype the additional characters that will make your text unique.After you have provided more input, press the ESC key again..SH Command Line EditingThe.PN cshcommand allows you to visually edit command lines using either a.PN vior.PN emacsenvironment. The.PN viinterface is modal and supports a subset of .PN vicommands. The.PN emacs interface is modeless and supports a subset of.PN emacscommands. See the Editing Interface section for a list of the available .PN viand .PN emacscommands..PPTo set the editing environment, define the Shell environmentvariable CSHEDIT as .PN vior .PN emacs .If the environment variable CSHEDIT is not defined, the.PN csh command searches for your EDITOR environment variable. When your EDITORenvironment variable is set to .PN vi ,.PN ex ,.PN edit ,or .PN ed ,the .PN cshcommand defaults to the .PN vicommand interface. If your EDITOR environment is not set to any ofthe previously mentioned editors, the default is the.PN emacscommand interface. Note that if neither the CSHEDIT or EDITORenvironment variables are defined, the .PN cshcommand defaults to the .PN vicommand interface..PPThe new history modifier (:v) allows you to pull commands from thehistory list to make them available for editing in visual edit mode. The symbol :v tells the Shell thatyou want to enter visual edit mode. For example, the following command line invokes edit mode for the previously typed .PN cpcommand line:.EX!cp:v.EEWhen you press the ESC key as the first character on a command line,it is equivalent to typing t
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?