SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from PLD akanga-1.0.7-2.i686.rpm

RC

Section: User Commands (1)
Updated: 28 April 1991
Index 

NAME

rc - shell 

SYNOPSIS

rc[-eixvldnpo][-ccommand][arguments] 

DESCRIPTION

rcis a command interpreter and programming language similar tosh(1).It is based on the AT&T Plan 9 shell of the same name.The shell offers a C-like syntax (much more so than the C shell),and a powerful mechanism for manipulating variables.It is reasonably small and reasonably fast,especially when compared to contemporary shells.Its use is intended to be interactive,but the language lends itself well to scripts. 

OPTIONS

R-e
If theR-eoption is present, thenrcwill exit if the exit status of a command is false (nonzero).rcwill not exit, however, if a conditional fails, e.g., anRif()command.
R-i
If theR-ioption is present or if the input torcis from a terminal (as determined byisatty(3))thenrcwill be ininteractivemode.That is, a prompt (fromR$prompt(1)R)R$prompt(1)will be printed before aninput line is taken, andrcwill ignore the signalsRSIGINTandRSIGQUITR.RSIGQUIT
R-x
This option will makercprint every command on standard error before it is executed.It can be useful for debuggingrcscripts.
R-v
This option will echo input torcon standard error as it is read.
R-l
If theR-loption is present, or ifrc'sRargv[0][0]is a dashR(R-R),R(R-R(thenrcwill behave as a login shell.That is, it will try to run commands present inR$home/.rcrcR,R$home/.rcrcif this file exists, before reading any other input.
R-d
This flag causesrcnot to ignoreRSIGQUITorRSIGTERMR.RSIGTERMThusrccan be made to dump core if sentRSIGQUITR.RSIGQUITThis option is only useful for debuggingrc.
R-n
This flag causesrcto read its input and parse it, but not to execute any commands.This is useful for syntax checking on scripts.If used in combination with theR-xoption,rcwill print each command as it is parsed in a form similar to the oneused for exporting functions into the environment.
R-p
This flag preventsrcfrom initializing shell functions from the environment.This allowsrcto run in a protected mode, whereby it becomes more difficult foranrcscript to be subverted by placing false commands in the environment.(Note that this presence of this option does NOT mean that it is safe torun setuidrcscripts; the usual caveats about the setuid bit still apply.)
R-o
This flag prevents the usual practice of trying to openR/dev/nullon file descriptors 0, 1, and 2, if any of those descriptorsare inherited closed.
R-c
IfR-cis present, commands are executed from the immediately followingargument.Any further arguments torcare placed inR$*R.R$*

 

COMMANDS

A simple command is a sequence of words, separated by white space(space and tab) characters that ends with a newline, semicolonR(R;R),R(R;R(or ampersandR(R&R).R(R&R(The first word of a command is the name of that command.If the name begins withR/R,R/R./R,R./orR../R,R../then the name is used as an absolute pathname referring to an executable file.Otherwise, the name of the command is looked up in a tableof shell functions, builtin commands,or as a file in the directories named byR$pathR.R$path 

Background Tasks

A command ending with aR&is run in the background; that is,the shell returns immediately rather than waiting for the command tocomplete.Background commands haveR/dev/nullconnected to their standard input unless an explicit redirection forstandard input is used. 

Subshells

A command prefixed with an at-signR(R@R)R(R@R(is executed in a subshell.This insulates the parent shell from the effectsof state changing operations such as acdor a variable assignment.For example:

R@ {cd ..; make}

will runmake(1)in the parent directoryR(R..R),R(R..R(but leaves the shell running in the current directory. 

Line continuation

A long logical line may be continued over several physical lines byterminating each line (except the last) with a backslashR(R\R).R(R\R(The backslash-newline sequence is treated as a space.A backslash is not otherwise special torc.(In addition,inside quotes a backslash loses its special meaningeven when it is followed by a newline.) 

Quoting

rcinterprets several characters specially; special charactersautomatically terminate words.The following characters are special:

R# ; & | ^ $ = ` ' { } ( ) < >

The single quoteR(R'R)R(R'R(prevents special treatment of any character other than itself.All characters, including control characters, newlines,and backslashes between two quote characters are treated as anuninterpreted string.A quote character itself may be quoted by placing two quotes in a row.The minimal sequence needed to enter the quote character isR''''R.R''''The empty string is represented byR''R.R''Thus:

Recho 'What''s the plan, Stan?'

prints out

RWhat's the plan, Stan?

The number signR(R#R)R(R#R(begins a comment inrc.All characters up to but not including the next newline are ignored.Note that backslash continuation does not work inside a comment,i.e.,the backslash is ignored along with everything else. 

Grouping

Zero or more commands may be grouped within bracesR(``R{R''R(``R{R(``andR``R}R''),R``R}R``and are then treated as one command.Braces do not otherwise define scope;they are used only for command grouping.In particular, be wary of the command:

Rfor (i) {R    commandR} | command

Since pipe binds tighter thanRforR,Rforthis command does not perform what the user expects it to.Instead, enclose the wholeRforstatement in braces:

R{for (i) command} | command

Fortunately,rc'sgrammar is simple enough that a (confident) user canunderstand it by examining the skeletalyacc(1)grammarat the end of this man page (see the section entitledGRAMMAR). 

Input and output

The standard output may be redirected to a file with

Rcommand > file

and the standard input may be taken from a file with

Rcommand < file

File descriptors other than 0 and 1 may be specified also.For example, to redirect standard error to a file, use:

Rcommand >[2] file

In order to duplicate a file descriptor, useR>[InR=ImR].R>[InR=ImR>[InR=R>[InR>[Thus to redirect both standard output and standard errorto the same file, use

Rcommand > file >[2=1]

To close a file descriptor that may be open, useR>[InR=].R>[InR>[For example, toclose file descriptor 7:

Rcommand >[7=]

In order to place the output of a command at the end of an alreadyexisting file, use:

Rcommand >> file

If the file does not exist, then it is created.

``Here documents'' are supported as inshwith the use of

Rcommand << 'eof-marker'

If the end-of-file marker is enclosed in quotes,then no variable substitution occurs inside the here document.Otherwise, every variable is substitutedby its space-separated-list value (seeFlat Lists,below),and if aR^character follows a variable name, it is deleted.This allows the unambiguous use of variables adjacent to text, as in

R$variable^follow

To include a literalR$in a here document when an unquoted end-of-file marker is being used,enter it asR$$R.R$$

Additionally,rcsupports ``here strings'', which are like here documents,except that input is taken directly from a string on the command line.Its use is illustrated here:

Rcat <<< 'this is a here string' | wc

(This feature enablesrcto export functions using here documents into the environment;the author does not expect users to find this feature useful.) 

Pipes

Two or more commands may be combined in a pipeline by placing thevertical barR(R|R)R(R|R(between them.The standard output (file descriptor 1)of the command on the left is tied to the standard input (filedescriptor 0) of the command on the right.The notationR|[InR=ImR]R|[InR=ImR|[InR=R|[InR|[indicates that file descriptornof the left process is connected tofile descriptormof the right process.R|[InR]R|[InR|[is a shorthand forR|[InR=0].R|[InR|[As an example, to pipe the standard error of a command towc(1),use:

Rcommand |[2] wc

The exit status of a pipeline is considered true if and only if everycommand in the pipeline exits true. 

Commands as Arguments

Some commands, likecmp(1)ordiff(1),take their arguments on the commandline, and do not read input from standard input.It is convenientsometimes to build nonlinear pipelines so that a command likecmpcan read the output of two other commands at once.rcdoes it like this:

Rcmp <{command} <{command}

compares the output of the two commands in braces.A note: since this form ofredirection is implemented with some kind of pipe, and since one cannotlseek(2)on a pipe, commands that uselseek(2)will hang.For example,most versions ofdiff(1)uselseek(2)on their inputs.

Data can be sent down a pipe to several commands usingtee(1)and the output version of this notation:

Recho hi there | tee >{sed 's/^/p1 /'} >{sed 's/^/p2 /'}
 

CONTROL STRUCTURES

The following may be used for control flow inrc: 

If-else Statements

Rif (ItestR) {Rif (ItestRif (
cmd

R} else IcmdR} else
Thetestis executed, and if its return status is zero, the firstcommand is executed, otherwise the second is.Braces are not mandatory around the commands.However, anRelsestatement is valid only if itfollows a close-brace on the same line.Otherwise, theRifis taken to be a simple-if:

Rif (test)R    command
 

While and For Loops

Rwhile (ItestR)I cmdRwhile (ItestR)Rwhile (ItestRwhile (
rcexecutes thetestand performs the command as long as thetestis true.
Rfor (IvarR inI listR)I cmdRfor (IvarR inI listR)Rfor (IvarR inI listRfor (IvarR inRfor (IvarRfor (
rcsetsvarto each element oflist(which may contain variables and backquote substitutions) and runscmd.IfR``RinR``list''is omitted, thenrcwill setvarto each element ofR$*(excludingR$0R).R$0For example:

Rfor (i in `{ls -F | grep '\*$' | sed 's/\*$//'}) { commands }
will setR$ito the name of each file in the current directory that isexecutable.
 

Switch

Rswitch (IlistR) { caseI ...R }Rswitch (IlistR) { caseI ...Rswitch (IlistR) { caseRswitch (IlistRswitch (
rclooks inside the braces after aRswitchfor statements beginning with the wordRcaseR.RcaseIf any of the patterns followingRcasematch the list supplied toRswitchR,Rswitchthen the commands up until the nextRcasestatement are executed.The metacharactersR*R,R*R[orR?should not be quoted;matching is performed only against the strings inlist,not against file names.(Matching for case statements is the same as for theR~command.)
 

Logical Operators

There are a number of operators inrcwhich depend on the exit status of a command.

Rcommand && command

executes the first command and then executes the second command if and only ifthe first command exits with a zero exit status (``true'' in Unix).

Rcommand || command

executes the first command and then executes the second command if and only ifthe first command exits with a nonzero exit status (``false'' in Unix).

R! command

negates the exit status of a command. 

PATTERN MATCHING

There are two forms of pattern matching inrc.One is traditional shell globbing.This occurs in matching for file names in argument lists:

Rcommand argument argument ...

When the charactersR*R,R*R[orR?occur in an argument or command,rclooks at theargument as a pattern for matching against files.(Contrary to the behavior other shells exhibit,rcwill only perform pattern matching if a metacharacter occurs unquoted andliterally in the input.Thus,

Rfoo='*'Recho $foo

will always echo just a star.In order for non-literal metacharacters to be expanded, anRevalstatement must be used in order to rescan the input.)Pattern matching occurs according to the following rules: aR*matches any number (including zero) ofcharacters.AR?matches any single character, and aR[followed by anumber of characters followed by aR]matches a single character in thatclass.The rules for character class matching are the same as those fored(1),with the exception that character class negation is achievedwith the tildeR(R~R),R(R~R(not the caretR(R^R),R(R^R(since the caret already meanssomething else inrc.

rcalso matches patterns against strings with theR~command:

R~ subject pattern pattern ...

R~setsR$statusto zero if and only if a supplied pattern matches anysingle element of the subject list.Thus

R~ foo f*

sets status to zero, while

R~ (bar baz) f*

sets status to one.The null list is matched by the null list, so

R~ $foo ()

checks to see whetherR$foois empty or not.This may also be achievedby the test

R~ $#foo 0

Note that inside aR~commandrcdoes not match patterns against filenames, so it is not necessary to quote the charactersR*R,R*R[andR?R.R?However,rcdoes expand the glob the subject against filenames if it containsmetacharacters.Thus, the command

R~ * ?

returns true if any of the files in the current directory have asingle-character name.(Note that if theR~command is given a list as its firstargument, then a successful match against any of the elements of thatlist will causeR~to return true.For example:

R~ (foo goo zoo) z*

is true.) 

LISTS AND VARIABLES

The primary data structure inrcis the list, which is a sequence of words.Parentheses are used to group lists.The empty list is represented byR()R.R()Lists have no hierarchical structure;a list inside another list is expanded so theouter list contains all the elements of the inner list.Thus, the following are all equivalent

Rone two threeR(one two three)R((one) () ((two three)))

Note that the null string,R''R,R''and the null list,R()R,R()are two verydifferent things.Assigning the null string to variable is a validoperation, but it does not remove its definition.For example,ifR$ais set toR''R,R''thenR$#aR,R$#areturns a 1. 

List Concatenation

Two lists may be joined by the concatenation operatorR(R^R).R(R^R(A single word is treated as a list of length one, so

Recho foo^bar

produces the output

Rfoobar

For lists of more than one element,concatenation works according to the following rules:if the two lists have the same number of elements,then concatenation is pairwise:

Recho (a- b- c-)^(1 2 3)

produces the output

Ra-1 b-2 c-3

Otherwise, one of the lists must have a single element,and then the concatenation is distributive:

Rcc -^(O g c) (malloc alloca)^.c

has the effect of performing the command

Rcc -O -g -c malloc.c alloca.c
 

Free Carets

rcinserts carets (concatenation operators) for free in certain situations,in order to save some typing on the user's behalf.Forexample, the above example could also be typed in as:

Ropts=(O g c) files=(malloc alloca) cc -$opts $files.c

rctakes care to insert a free-caret between theR``R-R''R``R-R``andR$optsR,R$optsas wellas betweenR$filesandR.cR.R.cThe rule for free carets is as follows: ifa word or keyword is immediatelyfollowed by another word, keyword, dollar-sign orbackquote, thenrcinserts a caret between them. 

Variables

A list may be assigned to a variable, using the notation:

IvarR = IlistIvarR = Ivar

Any sequence of non-special characters, except a sequence includingonly digits, may be used as a variable name.All user-defined variables are exported into the environment.

The value of a variable is referenced with the notation:

R$IvarR$

Any variable which has not been assigned a value returns the null list,R()R,R()when referenced.In addition, multiple references are allowed:

Ra=fooRb=aRecho $$b

prints

Rfoo

A variable's definition may also be removed byassigning the null list to a variable:

IvarR=()Ivar

For ``free careting'' to work correctly,rcmust make certain assumptionsabout what characters may appear in a variable name.rcassumes that a variable name consists only of alphanumeric characters,underscoreR(R_R)R(R_R(and starR(R*R).R(R*R(To reference a variable with othercharacters in its name, quote the variable name.Thus:

Recho $'we$IrdVariab!le'
 

Local Variables

Any number of variable assignments may be made local to a singlecommand by typing:

Ra=foo b=bar ... command

The command may be a compound command, so for example:

Rpath=. ifs=() {R    R...R    R}

setsRpathtoR.and removesRifsfor the duration of one long compound command. 

Variable Subscripts

Variables may be subscripted with the notation

R$var(InR)R$var(InR$var(

wherenis a list of integers (origin 1).The list of subscripts neednot be in order or even unique.Thus, if

Ra=(one two three)

then

Recho $a(3 3 3)

prints

Rthree three three

Ifnreferences a nonexistent element, thenR$var(InR)R$var(InR$var(returns the null list.The notationR$In,R$wherenis an integer, is a shorthand forR$*(InR).R$*(InR$*(Thus,rc'sarguments may be referred to asR$1R,R$1R$2R,R$2and so on.

Note also that the list of subscripts may be given by any ofrc'slist operations:

R$var(`{awk 'BEGIN{for(i=1;i<=10;i++)print i;exit; }'})

returns the first 10 elements ofR$varR.R$var

To count the number of elements in a variable, use

R$#var

This returns a single-element list, with the number of elements inR$varR.R$var 

Flat Lists

In order to create a single-element list from a multi-element list,with the components space-separated, use

R$^var

This is useful when the normal list concatenation rules need to bebypassed.For example, to append a single period at the end ofR$pathR,R$pathuse:

Recho $^path.
 

Backquote Substitution

A list may be formed from the output of a command by using backquotesubstitution:

R`{ command }

returns a list formed from the standard output of the command in braces.R$ifsis used to split the output into list elements.By default,R$ifshas the value space-tab-newline.The braces may be omitted if the command is a single word.ThusR`lsmay be used instead ofR`{ls}R.R`{ls}This last feature is useful when defining functions that expandto useful argument lists.A frequent use is:

Rfn src { echo *.[chy] }

followed by

Rwc `src

(This will print out a word-count of all C source files in the currentdirectory.)

In order to override the value ofR$ifsfor a single backquotesubstitution, use:

R`` (ifs-list) { command }

R$ifswill be temporarily ignored and the command's output will be split as specified bythe list following the double backquote.For example:

R`` ($nl :) {cat /etc/passwd}

splits upR/etc/passwdinto fields, assuming thatR$nlcontains a newlineas its value. 

SPECIAL VARIABLES

Several variables are known torcand are treated specially.
R*
The argument list ofrc.R$1, $2,etc. are the same asR$*(1)R,R$*(1)R$*(2)R,R$*(2)etc.The variableR$0holds the value ofRargv[0]with whichrcwas invoked.Additionally,R$0is set to the name of a function for the duration ofthe execution of that function, andR$0is also set to the name of thefile being interpreted for the duration of aR.command.
Rapid
The process ID of the last process started in the background.
Rapids
The process IDs of any background processes which are outstandingor which have died and have not been waited for yet.
Rcdpath
A list of directories to search for the target of acdcommand.The empty string stands for the current directory.Note that if theR$cdpathvariable does not contain the current directory, then the currentdirectory will not be searched; this allows directory searching tobegin in a directory other than the current directory.Note also that an assignment toR$cdpathcauses an automatic assignment toR$CDPATHR,R$CDPATHand vice-versa.
Rhistory
R$historycontains the name of a file to which commands are appended asrcreads them.This facilitates the use of a stand-alone history program(such ashistory(1))which parses the contents of the history file and presents them torcfor reinterpretation.IfR$historyis not set, thenrcdoes not append commands to any file.
Rhome
The default directory for the builtincdcommand and is the directoryin whichrclooks to find its initialization file,R.rcrcR,R.rcrcifrchas been started up as a login shell.LikeR$cdpathandR$CDPATHR,R$CDPATHR$homeandR$HOMEare aliased to each other.
Rifs
The internal field separator, used for splitting up the output ofbackquote commands for digestion as a list.
Rpath
This is a list of directories to search in for commands.The empty string stands for the current directory.Note that likeR$cdpathandR$CDPATHR,R$CDPATHR$pathandR$PATHare aliased to each other.IfR$pathorR$PATHis not set at startup time,R$pathassumes a default value suitable for your system.This is typicallyR(/usr/ucb /usr/bin /bin .)
Rpid
The process ID of the currently runningrc.
Rprompt
This variable holds the two prompts (in list form, of course) thatrcprints.R$prompt(1)is printed before each command is read, andR$prompt(2)is printed when input is expected to continue on the nextline.rcsetsR$prompttoR('; ' '')by default.The reason for this is that it enables anrcuser to grab commands from previous lines using amouse, and to present them torcfor re-interpretation; the semicolonprompt is simply ignored byrc.The nullR$prompt(2)also has itsjustification: anrcscript, when typed interactively, will not leaveR$prompt(2)R'sR$prompt(2)on the screen,and can therefore be grabbed by a mouse and placeddirectly into a file for use as a shell script, without further editingbeing necessary.
RpromptR (function)Rprompt
If this function is set, then it gets executed every timercis about to printR$prompt(1)R.R$prompt(1)
Rstatus
The exit status of the last command.If the command exited with a numeric value,that number is the status.If the died with a signal,the status is the name of that signal; if a core filewas created, the stringR``R+coreR''R``R+coreR``is appended.The value ofR$statusfor a pipeline is a list, with one entry,as above, for each process in the pipeline.For example, the command

Rls | wc
usually setsR$statustoR(0 0)R.R(0 0)

The values ofR$pathR,R$pathR$cdpathR,R$cdpathandR$homeare derived from the environmentvalues ofR$PATHR,R$PATHR$CDPATHR,R$CDPATHandR$HOMER.R$HOMEOtherwise, they are derived fromthe environment values ofR$pathR,R$pathR$cdpathandR$homeR.R$homeThis is for compatibility with other Unix programs, likesh(1).R$PATHandR$CDPATHare assumed to be colon-separated lists. 

FUNCTIONS

rcfunctions are identical torcscripts, except that they are storedin memory and are automatically exported into the environment.A shell function is declared as:

Rfn name { commands }

rcscans the definition until the close-brace, so the function canspan more than one line.The function definition may be removed by typing

Rfn name

(One or more names may be specified.With an accompanying definition, all names receive the same definition.This is sometimes usefulfor assigning the same signal handler to many signals.Without a definition, all named functions are deleted.)When a function is executed,R$*is set to the arguments to thatfunction for the duration of the command.Thus a reasonable definition forRlR,Rla shorthand forls(1),could be:

Rfn l { ls -FC $* }

but not

Rfn l { ls -FC }
 

INTERRUPTS AND SIGNALS

rcrecognizes a number of signals, and allows the user to define shellfunctions which act as signal handlers.rcby default trapsRSIGINTwhen it is in interactive mode.RSIGQUITandRSIGTERMare ignored, unlessrchas been invoked with theR-dflag.However, user-defined signal handlers may be written for these andall other signals.The way to define a signal handler is towrite a function by the name of the signal in lower case.Thus:

Rfn sighup { echo hangup; rm /tmp/rc$pid.*; exit }

In addition to Unix signals,rcrecognizes the artificial signalRSIGEXITwhich occurs asrcis about to exit.

In order to remove a signal handler's definition,remove it as though it were a regular function.For example:

Rfn sigint

returns the handler ofRSIGINTto the default value.In order to ignore a signal, set the signal handler's value toR{}R.R{}Thus:

Rfn sigint {}

causes SIGINT to be ignored by the shell.Only signals that are being ignored are passed on to programs run byrc;signal functions are not exported.

On System V-based Unix systems,rcwill not allow you to trapRSIGCLDR.RSIGCLD 

BUILTIN COMMANDS

Builtin commands execute in the context of the shell, but otherwisebehave exactly like other commands.Although!,~and@are not strictly speaking builtin commands,they can usually be used as such.
. [-i] file [arg ...]
Readsfileas input torcand executes its contents.With aR-iflag, input is interactive.Thus from within a shell script,

R. -i /dev/tty
does the ``right'' thing.
break
Breaks from the innermostRfororRwhileR,Rwhileas in C.It is an error to invokebreakoutside of a loop.(Note that there is nobreakkeyword between commands inRswitchstatements, unlike C.)
builtin command [arg ...]
Executes the command ignoring any function definition of thesame name.This command is present to allow functions with thesame names as builtins to use the underlying builtin or binary.
cd [directory]
Changes the current directory todirectory.The variableR$cdpathis searched for possible locations ofdirectory,analogous to the searching ofR$pathfor executable files.With no argument,cdchanges the current directory toR$homeR.R$home
echo [-n] [--] [arg ...]
Prints its arguments to standard output, terminated by a newline.Arguments are separated by spaces.If the first argument isR-nno final newline is printed.If the first argument isR--R,R--then all other arguments are echoed literally.This is used for echoing a literalR-nR.R-n
eval [list]
Concatenates the elements oflistwith spaces and feeds the resulting string torcfor re-scanning.This is the only time input is rescanned inrc.
exec [arg ...]
Replacesrcwith the given command.If the exec contains only redirections,then these redirections apply to the current shelland the shell does not exit.For example,

Rexec >[2] err.out
places further output to standard error in the fileerr.out.
exit [status]
Cause the current shell to exit with the given exitstatus.If no argument is given, the current value ofR$statusis used.
limit [-h] [resource [value]]
Similar to thecsh(1)limitbuiltin, this command operates upon theBSD-style limits of a process.TheR-hflag displays/alters the hardlimits.The resources which can be shown or altered arecputime,filesize,datasize,stacksize,coredumpsizeandmemoryuse.Forexample:

Rlimit coredumpsize 0
disables core dumps.
newpgrp
Putsrcinto a new process group.This builtin is useful for makingrcbehave like a job-control shell in a hostile environment.One example is the NeXT Terminal program, which implicitly assumesthat each shell it forks will put itself into a new process group.
return [n]
Returns from the current function, with statusn,wherenis a single value or a list of possible exit statuses.Thus it is legal to have

Rreturn (sigpipe 1 2 3)
(This is commonly used to allow a function to return with the exit statusof a previously executed pipeline of commands.)Ifnis omitted, thenR$statusis left unchanged.It is an error to invokereturnwhen not inside a function.
shift [n]
Deletesnelements from the beginning ofR$*and shifts the otherelements down byn.ndefaults to 1.(Note thatR$0is not affected byshift.)
umask [mask]
Sets the current umask (seeumask(2))to the octalmask.If no argument is present, the current mask value is printed.
wait [pid]
Waits for the specifiedpid,which must have been started byrc.If nopidis specified,rcwaits for all child processes to exit.
whatis [-s] [--] [name ...]
Prints a definition of the named objects.For variables, their valuesare printed; for functions, their definitions are; and for executablefiles, path names are printed.Without arguments,whatisprints the values of all shell variables and functions.With aR-sargument,whatisalso prints out a list of available signals and their handlers (if any).Note thatwhatisoutput is suitable for input torc;by saving the output ofwhatisin a file, it should be possible to recreate the state ofrcby sourcing this file with aR.command.Another note:Rwhatis -s > filecannot be used to store the state ofrc'ssignal handlers in a file, because builtins with redirectionsare run in a subshell, andrcalways restores signal handlers to their default value after aRfork()R.Rfork()
Sincewhatisusesgetopt(3)to parse its arguments, you can use the special argumentR--to terminate its options.This allows you to use names beginning with a dash, such asthehistory(1)commands.For example,

Rwhatis -- -p
 

GRAMMAR

Here isrc'sgrammar, edited to remove semantic actions.

R%term ANDAND BACKBACK BANG CASE COUNT DUP ELSE END FLAT FN FOR IF IN%term OROR PIPE REDIR SUB SUBSHELL SWITCH TWIDDLE WHILE WORD HUH%left WHILE ')' ELSE%left ANDAND OROR '\n'%left BANG SUBSHELL%left PIPE%right '$'%left SUB%start rc%%rc: line end        | error endend: END /* EOF */ | '\n'cmdsa: cmd ';' | cmd '&'line: cmd | cmdsa linebody: cmd | cmdsan bodycmdsan: cmdsa | cmd '\n'brace: '{' body '}'paren: '(' body ')'assign: first '=' wordepilog: /* empty */ | redir epilogredir: DUP | REDIR wordcase: CASE words ';' | CASE words '\n'cbody: cmd | case cbody | cmdsan cbodyiftail: cmd     %prec ELSE        | brace ELSE optnl cmdcmd     : /* empty */   %prec WHILE        | simple        | brace epilog        | IF paren optnl iftail        | FOR '(' word IN words ')' optnl cmd        | FOR '(' word ')' optnl cmd        | WHILE paren optnl cmd         | SWITCH '(' word ')' optnl '{' cbody '}'        | TWIDDLE optcaret word words        | cmd ANDAND optnl cmd        | cmd OROR optnl cmd        | cmd PIPE optnl cmd        | redir cmd     %prec BANG        | assign cmd    %prec BANG        | BANG optcaret cmd        | SUBSHELL optcaret cmd        | FN words brace        | FN wordsoptcaret: /* empty */ | '^'simple: first | simple word | simple redirfirst: comword | first '^' swordsword: comword | keywordword: sword | word '^' swordcomword: '$' sword        | '$' sword SUB words ')'        | COUNT sword        | FLAT sword        | '`' sword        | '`' brace        | BACKBACK word brace | BACKBACK word sword        | '(' words ')'        | REDIR brace        | WORDkeyword: FOR | IN | WHILE | IF | SWITCH        | FN | ELSE | CASE | TWIDDLE | BANG | SUBSHELLwords: /* empty */ | words wordoptnl: /* empty */ | optnl '\n'
 

FILES

R$HOME/.rcrcR,R$HOME/.rcrcR/tmp/rc*R,R/tmp/rc*R/dev/null 

CREDITS

rcwas written by Byron Rakitzis, with valuable helpfrom Paul Haahr, Hugh Redelmeier and David Sanderson.The design of this shell has been copied from thercthat Tom Duff wrote at Bell Labs. 

BUGS

On systems that supportR/dev/fdR,R/dev/fdR<{foo}style redirection is implemented that way.However, on other systems it is implemented with named pipes,and it is sometimespossible to foilrcinto removing the FIFO it places inR/tmpprematurely, or it is even possible to causercto hang.

The functionality ofshiftshould be available for variables other thanR$*R.R$*

echois built in only for performance reasons, which is a bad idea.

There should be a way to avoid exporting a variable.

TheR$^varnotation for flattening should allow for using an arbitraryseparating character, not just space.

Bug reports should be mailed toRbyronAATTarchone.tamu.eduR.RbyronAATTarchone.tamu.edu 

INCOMPATIBILITIES

Here is a list of features which distinguish this incarnation ofrcfrom the one described in the Bell Labs manual pages:

The treatment ofRifR-RelseRifR-Rifis different in the v10rc:that version uses anRif notclause which gets executedif the precedingRiftest does not succeed.

Backquotes are slightly different in v10rc:a backquote must always be followed by a left-brace.This restriction is not present for single-word commands in thisrc.

The following are all new with this version ofrc:TheR-noption,the list flattening operator,here strings (they facilitate exporting of functionswith here documents into the environment),thereturnandbreakkeywords,theechobuiltin,the support for the GNUreadline(3)library andthe support for theRpromptfunction.Thisrcalso setsR$0to the name of a function being executed/filebeing sourced. 

SEE ALSO

``rc --- A Shell for Plan 9 and UNIX Systems'',Unix Research System,10th Edition,vol. 2. (Saunders College Publishing)(This paper is also distributed with thisrcin PostScript form.)

history(1)


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
COMMANDS
Background Tasks
Subshells
Line continuation
Quoting
Grouping
Input and output
Pipes
Commands as Arguments
CONTROL STRUCTURES
If-else Statements
While and For Loops
Switch
Logical Operators
PATTERN MATCHING
LISTS AND VARIABLES
List Concatenation
Free Carets
Variables
Local Variables
Variable Subscripts
Flat Lists
Backquote Substitution
SPECIAL VARIABLES
FUNCTIONS
INTERRUPTS AND SIGNALS
BUILTIN COMMANDS
GRAMMAR
FILES
CREDITS
BUGS
INCOMPATIBILITIES
SEE ALSO

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector