|
|
1.1 ! root 1: .TH NEWCSH 1 ! 2: .UC 4 ! 3: .bd S 3 ! 4: .SH NAME ! 5: newcsh \- description of new csh features (over oldcsh) ! 6: .SH SYNOPSIS ! 7: .B csh ! 8: \fIcsh-options\fR ! 9: .SH SUMMARY ! 10: This is a summary of features new in ! 11: .IR csh (1) ! 12: in this version of the system; an older version of ! 13: .I csh ! 14: is available as ! 15: .I oldcsh. ! 16: This newer ! 17: .I csh ! 18: has some new process control primitives and a few other new features. ! 19: Users of ! 20: .I csh ! 21: must (and automatically) use the new terminal driver (summarized in ! 22: .IR newtty(4) ! 23: and completely described with the old in ! 24: .IR tty (4)) ! 25: which allows generation of some new ! 26: interrupt signals from the keyboard which tell jobs to stop, ! 27: and arbitrates access to the terminal; ! 28: on CRT's the command ``stty crt'' is ! 29: normally placed in the ! 30: .I .login ! 31: file to be executed at login, ! 32: to set other useful modes of this terminal driver. ! 33: .PP ! 34: .B "Jobs." ! 35: .PP ! 36: The most important new feature in this shell is the control of ! 37: .I jobs. ! 38: A job is associated with each pipeline, where a pipeline is either ! 39: a simple command like ``date'', or a pipeline like ``who | wc''. ! 40: The shell keeps a table of current jobs, and assigns them small ! 41: integer numbers. ! 42: When you start a job in the background, the shell prints a line ! 43: which looks like: ! 44: .PP ! 45: \ \ \ \ [1] 1234 ! 46: .PP ! 47: this indicating that the job which was started asynchronously with ``&'' ! 48: is job number 1 and has one (top-level) process, whose process id is 1234. ! 49: The set of current jobs is listed by the ! 50: .I jobs ! 51: command. ! 52: .PP ! 53: If you are running a job and wish to do something else you may hit the ! 54: key ^Z (control-Z) which sends a ! 55: .I stop ! 56: signal to the current job. The shell will then normally indicate that ! 57: the job has been ``Stopped'', and print another prompt. ! 58: You can then ! 59: put the job in the background with the command ``bg'', or run ! 60: some other commands and then return the job to the foreground with ! 61: ``fg''. ! 62: A ^Z takes effect immediately and is like an interrupt in that ! 63: pending output and unread input are discarded when it is typed. ! 64: There is another special key ^Y which does not generate a stop signal ! 65: until a program attempts to ! 66: .IR read (2) ! 67: it. ! 68: This can usefully be typed ahead when you have prepared some commands ! 69: for a job which you wish to stop after it has read them. ! 70: .PP ! 71: A job being run in the background will stop if it tries to read ! 72: from the terminal. Background jobs are normally allowed to produce output, ! 73: but this can be disabled by doing ``stty tostop''. If you set this ! 74: tty option, then background jobs will stop when they try to produce ! 75: output like they do when they try to read input. ! 76: .PP ! 77: There are several ways to refer to jobs in the shell. The character ! 78: ``%'' introduces a job name. If you wish to refer to job number 1, you can ! 79: name it as ``%1''. Just naming a job brings it to the foreground; thus ! 80: ``%1'' is a synonym for ``fg %1'', bringing job 1 back into the foreground. ! 81: Similarly saying ``%1 &'' resumes job 1 in the background. ! 82: Jobs can also be named by prefixes of the string typed in to start them, ! 83: if these prefixes are unambiguous, thus ``%ex'' would normally restart ! 84: a suspended ! 85: .IR ex (1) ! 86: job, if there were only one suspended job whose name began with ! 87: the string ``ex''. It is also possible to say ``%?string'' ! 88: which specifies a job whose text contains ! 89: .I string, ! 90: if there is only one such job. ! 91: .PP ! 92: The shell also maintains a notion of the current and previous jobs. ! 93: In output pertaining to jobs, the current job is marked with a ``+'' ! 94: and the previous job with a ``\-''. The abbreviation ``%+'' refers ! 95: to the current job and ``%\-'' refers to the previous job. For close ! 96: analogy with the ! 97: .I history ! 98: mechanism, ! 99: ``%%'' is also a synonym for the current job. ! 100: .PP ! 101: .B "Status reporting." ! 102: .PP ! 103: This shell learns immediately whenever a process changes state. ! 104: It normally informs you whenever a job becomes blocked so that ! 105: no further progress is possible, but only just before it prints ! 106: a prompt. This is done so that it does not otherwise disturb your work. ! 107: If, however, you set the shell variable ! 108: .I notify, ! 109: the shell will notify you immediately of changes of status in background ! 110: jobs. ! 111: There is also a shell command ! 112: .I notify ! 113: which marks a single process so that its status changes will be immediately ! 114: reported. By default ! 115: .I notify ! 116: marks the current process; ! 117: simply say ``notify'' after starting a background job to mark it. ! 118: .PP ! 119: When you try to leave the shell while jobs are stopped, you will ! 120: be warned that ``You have stopped jobs.'' You may use the ``jobs'' ! 121: command to see what they are. If you do this or immediately try to ! 122: exit again, the shell will not warn you a second time, and the suspended ! 123: jobs will be unmercifully terminated. ! 124: .PP ! 125: .B "New builtin commands." ! 126: .HP 5 ! 127: .B bg ! 128: .br ! 129: .ns ! 130: .HP 5 ! 131: \fBbg\ %\fRjob\ ... ! 132: .br ! 133: Puts the current or specified jobs into the background, continuing them ! 134: if they were stopped. ! 135: .HP 5 ! 136: .B fg ! 137: .br ! 138: .ns ! 139: .HP 5 ! 140: \fBfg\ %\fRjob\ ... ! 141: .br ! 142: Brings the current or specified jobs into the foreground, continuing them if ! 143: they were stopped. ! 144: .HP 5 ! 145: .B jobs ! 146: .br ! 147: .ns ! 148: .HP 5 ! 149: .B "jobs \-l" ! 150: .br ! 151: Lists the active jobs; given the ! 152: .B \-l ! 153: options lists process id's in addition to the normal information. ! 154: .HP 5 ! 155: \fBkill %\fRjob ! 156: .br ! 157: .ns ! 158: .HP 5 ! 159: \fBkill\ \-\fRsig\ \fB%\fRjob\ ... ! 160: .br ! 161: .ns ! 162: .HP 5 ! 163: \fBkill\fR\ pid ! 164: .br ! 165: .ns ! 166: .HP 5 ! 167: \fBkill\ \-\fRsig\ pid\ ... ! 168: .br ! 169: .ns ! 170: .HP 5 ! 171: \fBkill\ \-l\fR ! 172: .br ! 173: Sends either the TERM (terminate) signal or the ! 174: specified signal to the specified jobs or processes. ! 175: Signals are either given by number or by names (as given in ! 176: .I /usr/include/signal.h, ! 177: stripped of the prefix ``SIG''). ! 178: The signal names are listed by ``kill \-l''. ! 179: There is no default, saying just `kill' does not ! 180: send a signal to the current job. ! 181: If the signal being sent is TERM (terminate) or HUP (hangup), ! 182: then the job or process will be sent a CONT (continue) signal as well. ! 183: .HP 5 ! 184: .B notify ! 185: .br ! 186: .ns ! 187: .HP 5 ! 188: \fBnotify\ %\fRjob\ ... ! 189: .br ! 190: Causes the shell to notify the user asynchronously when the status of the ! 191: current or specified jobs changes; normally notification is presented ! 192: before a prompt. All jobs are marked ``notify'' if the shell variable ! 193: ``notify'' is set. ! 194: .HP 5 ! 195: \fBstop\ %\fRjob\ ... ! 196: .br ! 197: Stops the specified job which is executing in the background. ! 198: .HP 5 ! 199: \fB%\fRjob ! 200: .br ! 201: Brings the specified job into the foreground. ! 202: .HP 5 ! 203: \fB%\fRjob \fB&\fR ! 204: .br ! 205: Continues the specified job in the background. ! 206: .br ! 207: .ne 5 ! 208: .PP ! 209: .B "Process limitations." ! 210: .PP ! 211: The shell provides access to an experimental facility for limiting ! 212: the consumption by a single process of system resources. ! 213: The following commands control this facility: ! 214: .HP 5 ! 215: \fBlimit\fR \fIresource\fR \fImaximum-use\fR ! 216: .HP 5 ! 217: \fBlimit\fR \fIresource\fR ! 218: .br ! 219: .ns ! 220: .HP ! 221: \fBlimit\fR ! 222: .br ! 223: Limits the consumption by the current process and each process ! 224: it creates to not individually exceed \fImaximum-use\fR on the ! 225: specified \fIresource\fR. If no \fImaximum-use\fR is given, then ! 226: the current limit is printed; if no \fIresource\fR is given, then ! 227: all limitations are given. ! 228: .IP ! 229: Resources controllable currently include \fIcputime\fR (the maximum ! 230: number of cpu-seconds to be used by each process), \fIfilesize\fR ! 231: (the largest single file which can be created), \fIdatasize\fR ! 232: (the maximum growth of the data+stack region via ! 233: .IR sbrk (2) ! 234: beyond the end of the program text), \fIstacksize\fR (the maximum ! 235: size of the automatically-extended stack region), and \fIcoredumpsize\fR ! 236: (the size of the largest core dump that will be created). ! 237: .IP ! 238: The \fImaximum-use\fR may be given as a (floating point or integer) ! 239: number followed by a scale factor. For all limits other than \fIcputime\fR ! 240: the default scale is ``k'' or ``kilobytes'' (1024 bytes); ! 241: a scale factor of ``m'' or ``megabytes'' may also be used. ! 242: For cputime the default scaling is ``seconds'', while ``m'' for minutes ! 243: or ``h'' for hours, or a time of the form ``mm:ss'' giving minutes ! 244: and seconds may be used. ! 245: .IP ! 246: For both \fIresource\fR names and scale factors, unambiguous prefixes ! 247: of the names suffice. ! 248: .HP 5 ! 249: \fBunlimit\fR \fIresource\fR ! 250: .br ! 251: .ns ! 252: .HP 5 ! 253: \fBunlimit\fR ! 254: .br ! 255: Removes the limitation on \fIresource\fR. If no \fIresource\fR ! 256: is specified, then all \fIresource\fR limitations are removed. ! 257: .ne 5 ! 258: .PP ! 259: .B "Directory stack." ! 260: .PP ! 261: This shell now keeps track of the current directory (which is kept ! 262: in the variable ! 263: .I cwd) ! 264: and also maintains a stack of directories, which is printed by the ! 265: command ! 266: .I dirs. ! 267: You can change to a new directory and push down the old directory ! 268: stack by using the command ! 269: .I pushd ! 270: which is otherwise like the ! 271: .I chdir ! 272: command, changing to its argument. ! 273: You can pop the directory stack by saying ! 274: .I popd. ! 275: Saying ! 276: .I pushd ! 277: with no arguments exchanges the top two elements of the directory stack. ! 278: The elements of the directory stack are numbered from 1 starting at the top. ! 279: Saying ! 280: .I pushd ! 281: with a argument ``+\fIn\fR'' rotates the directory stack to make that entry ! 282: in the stack be at the top and changes to it. ! 283: Giving ! 284: .I popd ! 285: a ``+\fIn\fR'' argument eliminates that argument from the directory stack. ! 286: .PP ! 287: .B "Miscellaneous." ! 288: .PP ! 289: This shell imports the environment variable USER into the variable ! 290: .I user, ! 291: TERM into ! 292: .I term, ! 293: and ! 294: HOME into ! 295: .I home, ! 296: and exports these back into the environment whenever the normal ! 297: shell variables are reset. ! 298: The environment variable PATH is likewise handled; it is not ! 299: necessary to worry about its setting other than in the file ! 300: .I \&.cshrc ! 301: as inferior ! 302: .I csh ! 303: processes will import the definition of ! 304: .I path ! 305: from the environment, and re-export it if you then change it. ! 306: (It could be set once in the ! 307: .I \&.login ! 308: except that commands over the Berknet would not ! 309: see the definition.) ! 310: .PP ! 311: There are new commands ! 312: .I eval, ! 313: which is like the eval of the Bourne shell ! 314: .IR sh (1), ! 315: and useful with ! 316: .IR tset (1), ! 317: and ! 318: .I suspend ! 319: which stops a shell (as though a ^Z had stopped it; since ! 320: shells normally ignore ^Z signals, this command is necessary.) ! 321: .PP ! 322: There is a new variable ! 323: .I cdpath; ! 324: if set, then each directory in ! 325: .I cdpath ! 326: will be searched for a directory named in a ! 327: .I chdir ! 328: command if there is no such subdirectory of the current directory. ! 329: .PP ! 330: An ! 331: .I unsetenv ! 332: command removing environment variables has been added. ! 333: .PP ! 334: There is a new ``:'' modifier ``:e'', which yields the extension ! 335: portion of a filename. Thus if ``$a'' is ``file.c'', ``$a:e'' is ``c''. ! 336: .PP ! 337: There are two new operators in shell expressions ``!~'' and ``=~'' which ! 338: are like the string operations ``!='' and ``=='' except that the right ! 339: hand side is a ! 340: .I pattern ! 341: (containing, e.g. ``*''s, ``?''s and instances of ``[...]'') ! 342: against which the left hand operand is matched. This reduces the ! 343: need for use of the ! 344: .I switch ! 345: statement in shell scripts when all that is really needed is pattern matching. ! 346: .PP ! 347: The form ``$<'' is new, and is replaced by a line from the standard ! 348: input, with no further interpretation thereafter. It may therefore ! 349: be used to read from the keyboard in a shell script. ! 350: .SH "SEE ALSO" ! 351: csh(1), killpg(2), sigsys(2), signal(2), jobs(3), sigset(3), tty(4) ! 352: .SH BUGS ! 353: Command sequences of the form ``a ; b ; c'' are not handled gracefully ! 354: when stopping is attempted. If you suspend ``b'', the shell will then ! 355: immediately execute ``c''. This is especially noticeable if this ! 356: expansion results from an ! 357: .I alias. ! 358: It suffices to place the sequence of commands in ()'s to force it to ! 359: a subshell, i.e. ``( a ; b ; c )'', but see the next bug. ! 360: .PP ! 361: Shell builtin functions are not stoppable/restartable. ! 362: .PP ! 363: Control over output is primitive; ! 364: perhaps this will inspire someone to work on a good virtual ! 365: terminal interface. In a virtual terminal interface much more ! 366: interesting things could be done with output control.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.