unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Page:
Section:
Apropos / Subsearch:
optional field



 sh-bourne(1)							sh-bourne(1)




 NAME
      sh, rsh - Bourne shell, the standard/restricted command programming
      language

 SYNOPSIS
      sh [--acefhiknrstuvx ...] [arg ...]

      rsh [--acefhiknrstuvx ...] [arg ...]

 DESCRIPTION
      sh is a command programming language that executes commands read from
      a terminal or a file.  rsh is a restricted version of the standard
      command interpreter sh; it is used to set up login names and execution
      environments whose capabilities are more controlled than those of the
      standard shell.  See ``Invocation'' and ``Special Commands'' sections
      later in this entry for details about command line options and
      arguments, particularly the set command.

    Definitions
      A blank is a tab or a space character.  A name is a sequence of
      letters, digits, or underscores beginning with a letter or underscore.
      A parameter is a name, a digit, or any of the characters *, @, #, ?,
      -, $, and !.

    Commands
      A simple-command is a sequence of non-blank words separated by blanks.
      The first word specifies the name of the command to be executed.
      Except as specified below, the remaining words are passed as arguments
      to the invoked command.  The command name is passed as argument 0 (see
      exec(2)).	 The value of a simple-command is its exit status if it
      terminates normally, or (octal) 200+status if it terminates abnormally
      (see signal(5) for a list of status values).

      A pipeline is a sequence of one or more commands separated by | (or,
      for historical compatibility, by ^).  The standard output of each
      command except the last is connected by a pipe(2) to the standard
      input of the next command.  Each command is run as a separate process
      and the shell waits for the last command to terminate.  The exit
      status of a pipeline is the exit status of the last command.

      A list is a sequence of one or more pipelines separated by ;, &&amp&amp&, &&amp&amp&&&amp&amp&,
      or ||, and optionally terminated by ; or &&amp&amp&.  Of these four symbols, ;
      and &&amp&amp& have equal precedence, which is lower than that of &&amp&amp&&&amp&amp& and ||.
      The symbols &&amp&amp&&&amp&amp& and || also have equal precedence.	 A semicolon (;)
      causes sequential execution of the preceding pipeline; an ampersand
      (&&amp&amp&) causes asynchronous execution of the preceding pipeline (i.e., the
      shell does not wait for that pipeline to finish).	 The symbol &&amp&amp&&&amp&amp& (||)
      causes the list following it to be executed only if the preceding
      pipeline returns a zero (non-zero) exit status.  An arbitrary number
      of new-line characters instead of semicolons can appear in a list to
      delimit commands.



 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      A command is either a simple-command or one of the following.  Unless
      otherwise stated, the value returned by a command is that of the last
      simple-command executed in the command.

      for name [ in word ... ] do list done
		     Each time a for command is executed, name is set to the
		     next word taken from the in word list.  If in word ...
		     is omitted, the for command executes the do list once
		     for each positional parameter that is set (see
		     Parameter Substitution below).  Execution ends when
		     there are no more words in the list.

      case word in [pattern [|	pattern] ... ) list ;;] ... esac
		     A case command executes the list associated with the
		     first pattern that matches word.  The form of the
		     patterns is the Pattern Matching Notation as qualified
		     for the case command (see regexp(5)).

      if list then list [ elif list then list ] ... [ else list ] fi
		     The list following if is executed and, if it returns a
		     zero exit status, the list following the first then is
		     executed.	Otherwise, the list following elif is
		     executed and, if its value is zero, the list following
		     the next then is executed.	 Failing that, the else list
		     is executed.  If no else list or then list is executed,
		     the if command returns a zero exit status.

      while list do list done
		     A while command repeatedly executes the while list and,
		     if the exit status of the last command in the list is
		     zero, executes the do list; otherwise the loop
		     terminates.  If no commands in the do list are
		     executed, the while command returns a zero exit status;
		     until can be used in place of while to negate the loop
		     termination test.

      (list)	     Execute list in a sub-shell.

      {list;}	     The purpose of using braces is to allow the aggregate
		     output from list to be redirected elsewhere.  If
		     redirection is used as in:

		     {list;} >&gt&gt>file

		     a subshell is created to execute list.  This implies
		     that any shell variables set, created, or modified
		     within the {} do not retain their values outside the
		     {}.  If no redirection is used, a subshell is not
		     created, and shell modifications made within the {} are
		     preserved.




 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      name () {list;}
		     Define a function which is referenced by name. The body
		     of the function is the list of commands between { and
		     }.	 Execution of functions is described below (see
		     ``Execution'').

      The following words are recognized only as the first word of a
      command, and when not quoted:

	   if then else elif fi case esac for while until do done { }

    Comments
      A word beginning with # causes that word and all the following
      characters up to a new-line character to be ignored.

    Command Substitution
      The standard output from a command enclosed in a pair of grave accents
      (``) can be used as part or all of a word; trailing new-lines are
      removed.

    Parameter Substitution
      The $ character is used to introduce substitutable parameters.  There
      are two types of parameters, positional and keyword.  If parameter is
      a digit, it is a positional parameter.  Positional parameters can be
      assigned values by set.  Keyword parameters (also known as variables)
      can be assigned values by writing:

	   name=value[name=value]...

      Pattern-matching is not performed on value.  Having a function and a
      variable with the same name is not allowed.

      ${parameter}   The value, if any, of the parameter is substituted.
		     Braces are required only when parameter is followed by
		     a letter, digit, or underscore that is not to be
		     interpreted as part of its name.  If parameter is * or
		     @, all positional parameters, starting with $1, are
		     substituted (separated by spaces).	 Parameter $0 is set
		     from argument zero when the shell is invoked.

      ${parameter:-word}
		     If parameter is set and is non-null, substitute its
		     value; otherwise substitute word.

      ${parameter:=word}
		     If parameter is not set or is null, set it to word; the
		     value of the parameter is then substituted.  Positional
		     parameters cannot be assigned to in this way.

      ${parameter:?word}
		     If parameter is set and is non-null, substitute its



 Hewlett-Packard Company	    - 3 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




		     value; otherwise, print word and exit from the shell.
		     If word is omitted, the message ``parameter null or not
		     set'' is printed.

      ${parameter:+word}
		     If parameter is set and is non-null, substitute word;
		     otherwise substitute nothing.

      In the above, word is not evaluated unless it is to be used as the
      substituted string.  Thus, in the following example, pwd is executed
      only if d is not set or is null:

	   echo ${d:-`pwd`}

      If the colon (:) is omitted from the above expressions, the shell only
      checks whether parameter is set or not.

      The following parameters are automatically set by the shell:

	   #		  The number of positional parameters in decimal.

	   -		  Flags supplied to the shell on invocation or by
			  the set command.

	   ?		  The decimal value returned by the last
			  synchronously executed command.

	   $		  The process id of the last separately-invoked
			  shell (i.e., a shell arising from direct
			  invocation or #!).  This parameter is not updated
			  for subshells arising from (), command
			  substitution, etc.

	   !		  The process number of the last background command
			  invoked.

	   LINES
	   COLUMNS	  The number of lines and columns in the current
			  display area.	 These parameters are set only under
			  specific circumstances.  See Signals.

      The following parameters are used by the shell:

	   HOME		  The default argument (home directory) for the cd
			  command.

	   PATH		  The search path for commands (see ``Execution''
			  below).  Users executing under rsh cannot change
			  PATH.





 Hewlett-Packard Company	    - 4 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




	   CDPATH	  The search path for the cd command.

	   MAIL		  If this parameter is set to the name of a mail
			  file and the MAILPATH parameter is not set, the
			  shell informs the user of the arrival of mail in
			  the specified file.

	   MAILCHECK	  This parameter specifies how often (in seconds)
			  the shell will check for the arrival of mail in
			  the files specified by the MAILPATH or MAIL
			  parameters.  The default value is 600 seconds (10
			  minutes).  If set to 0, the shell checks before
			  each prompt.

	   MAILPATH	  A colon (:)-separated list of file names.  If this
			  parameter is set, the shell informs the user of
			  the arrival of mail in any of the specified files.
			  Each file name can be followed by % and a message
			  to be printed when the modification time changes.
			  The default message is you have mail.

	   PS1		  Primary prompt string, by default ``$ ''.

	   PS2		  Secondary prompt string, by default ``>&gt&gt> ''.

	   IFS		  Internal field separators, normally space, tab,
			  and new-line.

	   SHACCT	  If this parameter is set to the name of a file
			  writable by the user, the shell writes an
			  accounting record in the file for each shell
			  procedure executed.  Accounting routines such as
			  acctcom(1M) and acctcms(1M) can be used to analyze
			  the data collected.

	   SHELL	  When the shell is invoked, it scans the
			  environment (see ``Environment'' below) for this
			  name.	 If it is found and there is an r in the
			  file name part of its value, the shell becomes a
			  restricted shell.  SHELL is also used by some
			  processors to determine which command interpreter
			  to run.

      The shell gives default values to PATH, PS1, PS2, MAILCHECK, and IFS.
      HOME and MAIL are set by login(1).

    Blank Interpretation
      After parameter and command substitution, the results of substitution
      are scanned for internal field separator characters (those found in
      IFS) and split into distinct arguments where such characters are
      found.  Explicit null arguments ("" or '') are retained.	Implicit



 Hewlett-Packard Company	    - 5 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      null arguments (those resulting from parameters that have no values)
      are removed.

    File Name Generation
      Following substitution, each command word is processed as a pattern
      for file name expansion.	The form of the patterns is the Pattern
      Matching Notation defined by regexp(5).

    Quoting
      The following characters have a special meaning to the shell and cause
      termination of a word unless quoted:

	   ;, &&amp&amp&amp;, (, ), |, ^, <&lt&lt&lt;, >&gt&gt&gt;, new-line, space, tab, # (comment)

      A character can be quoted (i.e., made to stand for itself) by
      preceding it with a \.  The pair \new-line is ignored.  All characters
      enclosed between a pair of single quote marks (''), except a single
      quote, are quoted.  Inside double quote marks (""), parameter and
      command substitution occurs and \ quotes the characters \, `, ", and
      $.  "$*" is equivalent to "$1 $2 ...", whereas "$@" is equivalent to
      "$1""$2" ....

    Prompting
      When used interactively, the shell prompts with the value of PS1
      before reading a command.	 If at any time a new-line is typed and
      further input is needed to complete a command, the secondary prompt
      (i.e., the value of PS2) is issued.

    Input/Output
      Before a command is executed, its input and output can be redirected
      using a special notation interpreted by the shell.  The following can
      appear anywhere in a simple-command or can precede or follow a command
      and are not passed on to the invoked command; substitution occurs
      before word or digit is used:

	   <&lt&lt&lt;word	 Use file word as standard input (file descriptor
			 0).

	   >&gt&gt&gt;word	 Use file word as standard output (file descriptor
			 1).  If the file does not exist then it is created;
			 otherwise, it is truncated to zero length.

	   >&gt&gt&gt;>&gt&gt&gt;word	 Use file word as standard output.  If the file
			 exists then output is appended to it (by first
			 seeking to the end-of-file); otherwise, the file is
			 created.

	   <&lt&lt&lt;<&lt&lt&lt;[-]word	 The shell input is read up to a line that is the
			 same as word, or to an end-of-file.  The resulting
			 document becomes the standard input.  If any
			 character of word is quoted, no interpretation is



 Hewlett-Packard Company	    - 6 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




			 placed upon the characters of the document;
			 otherwise, parameter and command substitution
			 occurs, (unescaped) \new-line is ignored, and \
			 must be used to quote the characters \, $, `, and
			 the first character of word.  If - is appended to
			 <&lt&lt&lt;<&lt&lt&lt;, all leading tabs are stripped from word and
			 from the document.

	   <&lt&lt&lt;&&amp&amp&amp;digit	 Use the file associated with file descriptor digit
			 as standard input.  Similarly for the standard
			 output using >&gt&gt&gt;&&amp&amp&amp;digit (see dup(2)).  Note that digit
			 must be in the range 0 through 9.

	   <&lt&lt&lt;&&amp&amp&amp;-		 The standard input is closed.	Similarly for the
			 standard output using >&gt&gt&gt;&&amp&amp&amp;-.

      If any of the above is preceded by a digit in the range 0 through 9,
      the file descriptor that becomes associated with the file is that
      specified by the digit (rather than the default 0 or 1).	For example:

	   ... 2>&gt&gt&gt;&&amp&amp&amp;1

      associates file descriptor 2 with the file currently associated with
      file descriptor 1.  Note that this type of I/O redirection is
      necessary when synchronously collecting standard output and standard
      error output in the same file.  Redirecting standard output and
      standard error separately causes asynchronous collection of data at
      the destination (information written to standard output can be
      subsequently over-written by information written to standard error and
      vice-versa).

      The order in which redirections are specified is significant.  The
      shell evaluates redirections left-to-right.  For example:

	   ... 1>&gt&gt&gt;xxx 2>&gt&gt&gt;&&amp&amp&amp;1

      first associates file descriptor 1 with file xxx.	 It associates file
      descriptor 2 with the file associated with file descriptor 1 (i.e.
      xxx).  If the order of redirections is reversed, file descriptor 2 is
      associated with the terminal (assuming file descriptor 1 was
      originally) and file descriptor 1 is associated with file xxx.

      If a command is followed by &&amp&amp&amp;, the default standard input for the
      command is the empty file /dev/null.  Otherwise, the environment for
      executing a command contains the file descriptors of the invoking
      shell as modified by input/output specifications.

      Redirection of output is not allowed in the restricted shell.

    Environment
      The environment (see environ(5)) is a list of name-value pairs that is



 Hewlett-Packard Company	    - 7 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      passed to an executed program in the same way as a normal argument
      list.  The shell interacts with the environment in several ways.	On
      invocation, the shell scans the environment and creates a parameter
      for each name found, giving it the corresponding value.  Executed
      commands inherit the same environment.  If the user modifies the value
      of any of these parameters or creates new parameters, none of these
      affects the environment unless the export command is used to bind the
      shell's parameter to the environment (see also set -a).  To remove a
      parameter from the environment, use the unset command.  The
      environment seen by any executed command is thus composed of any
      unmodified name-value pairs originally inherited by the shell, minus
      any pairs removed by unset, plus any modifications or additions, all
      of which must be noted in export commands.

      The environment for any simple-command can be augmented by prefixing
      it with one or more assignments to parameters.  Thus:

	   TERM=450 cmd

      and

	   (export TERM; TERM=450; cmd)

      are equivalent (as far as the execution of cmd is concerned).

      If the -k option is set, all keyword arguments are placed in the
      environment, even if they occur after the command name.  The following
      first prints a=b c and then c:

	   echo a=b c
	   set -k
	   echo a=b c

    Signals
      The INTERRUPT and QUIT signals for an invoked command are ignored if
      the command is followed by &&amp&amp&amp; and the command does not override the
      SIGINT and SIGQUIT signal settings it inherited from /usr/old/bin/sh;
      otherwise signals have the values inherited by the shell from its
      parent, with the exception of signal 11 (but see also the trap command
      below).

      If a SIGWINCH signal is received, sh determines the new size of the
      display area and resets the values of the LINES and COLUMNS variables
      appropriately.  Note that the value of either variable is modified
      only if that variable exists at the time SIGWINCH is received.  sh
      does not create these variables.	Any traps set on SIGWINCH are
      executed immediately after LINES and COLUMNS are reset.

    Execution
      Each time a command is executed, the above substitutions are carried
      out.  If the command name matches one of the Special Commands listed



 Hewlett-Packard Company	    - 8 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      below, it is executed in the shell process.  If the command name does
      not match a Special Command, but matches the name of a defined
      function, the function is executed in the shell process (note how this
      differs from the execution of shell procedures).	The positional
      parameters $1, $2, ....  are set to the arguments of the function.  If
      the command name matches neither a Special Command nor the name of a
      defined function, a new process is created and an attempt is made to
      execute the command via exec(2).

      The shell parameter PATH defines the search path for the directory
      containing the command.  Alternative directory names are separated by
      a colon (:).  The default path is :/usr/bin (specifying the current
      directory and /usr/bin, in that order).  Note that the current
      directory is specified by a null path name, which can appear
      immediately after the equal sign or between the colon delimiters
      anywhere else in the path list.  If the command name contains a / the
      search path is not used (such commands are not executed by the
      restricted shell).  Otherwise, each directory in the path is searched
      for an executable file.  If the file has execute permissions but is
      not a directory or an executable object code file, it is assumed to be
      a script file which is a file of data for an interpreter.	 If the
      first two characters of the script file are #!, exec (see exec(2))
      expects an interpreter path name to follow.  exec then attempts to
      execute the specified interpreter as a separate process to read the
      entire script file.  If a call to exec fails, /usr/old/bin/sh is
      spawned to interpret the script file.

      A parenthesized command is also executed in a sub-shell.	The location
      in the search path where a command was found is remembered by the
      shell (to help avoid unnecessary execs later).  If the command was
      found in a relative directory, its location must be re-determined
      whenever the current directory changes.  The shell forgets all
      remembered locations whenever the PATH variable is changed or the hash
      -r command is executed (see below).

    Special Commands
      The following commands are executed in the shell process.
      Input/output redirection is permitted for these commands.	 File
      descriptor 1 is the default output location.

      :			  No effect; the command does nothing.	A zero exit
			  code is returned.

      . file		  Read and execute commands from file and return.
			  The search path specified by PATH is used to find
			  the directory containing file.  Note that this
			  command does not spawn another shell to execute
			  file, and thus differs in behavior and output from
			  executing file as a shell script.  It is not
			  necessary that the execute permission bit be set
			  for file.



 Hewlett-Packard Company	    - 9 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      break [n]		  Exit from the enclosing for or while loop, if any.
			  If n is specified, break n levels.

      continue [n]	  Resume the next iteration of the enclosing for or
			  while loop.  If n is specified, resume at the n-th
			  enclosing loop.

      cd [arg]		  Change the current directory to arg.	The shell
			  parameter HOME is the default arg.  The shell
			  parameter CDPATH defines the search path for the
			  directory containing arg.  Alternative directory
			  names are separated by a colon (:).  The default
			  path is null (meaning the current directory).
			  Note that the current directory is specified by a
			  null path name, which can appear immediately after
			  the equal sign or between the colon delimiters
			  anywhere else in the path list.  If arg begins
			  with a / the search path is not used.	 Otherwise,
			  each directory in the path is searched for arg.
			  The cd command cannot be executed by rsh.  See
			  also cd(1).

      echo [arg ...]	  Echo arguments. See echo(1) for usage and
			  description.

      eval [arg ...]	  The arguments are read as input to the shell and
			  the resulting command(s) executed.

      exec [arg ...]	  The command specified by the arguments is executed
			  in place of this shell without creating a new
			  process.  Input/output arguments can appear and,
			  if no other arguments are given, cause the shell
			  input/output to be modified.

      exit [n]		  Causes a shell to exit with the exit status
			  specified by n.  If n is omitted, the exit status
			  is that of the last command executed (an end-of-
			  file also causes the shell to exit.)

      export [name ...]	  The given names are marked for automatic export to
			  the environment of subsequently-executed commands.
			  If no arguments are given, a list of names
			  currently included in the environment are printed.
			  Function names cannot be exported.

      hash [-r] [name ...]
			  For each name, the location in the search path of
			  the command specified by name is determined and
			  remembered by the shell.  The -r option causes the
			  shell to forget all remembered locations.  If no
			  arguments are given, information about remembered



 Hewlett-Packard Company	   - 10 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




			  commands is presented.  hits is the number of
			  times a command has been invoked by the shell
			  process.  cost is a measure of the work required
			  to locate a command in the search path.  Certain
			  situations require that the stored location of a
			  command be recalculated.  Commands for which this
			  will be done are indicated by an asterisk (*)
			  adjacent to the hits information.  cost is
			  incremented when the recalculation is done.

      newgrp [arg ...]	  Equivalent to exec newgrp arg ....  See newgrp(1)
			  for usage and description.

      pwd		  Print the current working directory.	See also
			  pwd(1).

      read name ...	  One line is read from the standard input and the
			  first word is assigned to the first name, the
			  second word to the second name, etc., with
			  leftover words assigned to the last name.  The
			  return code is 0 unless an end-of-file is
			  encountered.

			  Note that although the read command is a built-in
			  command and is generally executed directly by the
			  shell, this is not the case when it is used in a
			  pipeline.  In a pipeline, a new shell is forked to
			  execute the read command with the result that any
			  shell variables set are not available to the
			  parent shell when the pipeline is finished.  This
			  has the effect of making the read command useless
			  in a pipeline.  See also read(1).

      readonly [name ...] The given names are marked readonly and the values
			  of the these names cannot be changed by subsequent
			  assignment.  If no arguments are given, a list of
			  all readonly names is printed.

      return [n]	  Causes a function to exit with the return value
			  specified by n.  If n is omitted, the return
			  status is that of the last command executed.

      set [--aefhkntuvx [arg ...]]
			  set sets or unsets options, and resets the values
			  of the positional parameters to the args given, if
			  any.	The option list is terminated by the first
			  argument that does not begin with - or +, or upon
			  encountering an argument consisting entirely of -
			  -.  Recognized options are:





 Hewlett-Packard Company	   - 11 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




			  -a   Mark variables which are modified or created
			       for export.

			  -e   Exit immediately if a command exits with a
			       non-zero exit status.

			  -f   Disable file name generation

			  -h   Locate and remember function commands as
			       functions are defined (function commands are
			       normally located when the function is
			       executed).

			  -k   All keyword arguments are placed in the
			       environment for a command, not just those
			       that precede the command name.

			  -n   Read commands but do not execute them.

			  -t   Exit after reading and executing one command.

			  -u   Treat unset variables as an error when
			       substituting.

			  -v   Print shell input lines as they are read.

			  -x   Print commands and their arguments as they
			       are executed.

			  --   Do not change any of the options; useful when
			       $1 is to be set to a string beginning with -
			       or +.

			  Using + rather than - causes these options to be
			  unset.  These options can also be used upon
			  invocation of the shell.  The current set of
			  options can be found in $-.  The remaining
			  arguments are positional parameters and are
			  assigned, in order, to $1, $2, ....  If no
			  arguments are given, the values of all names are
			  printed.

      shift [n]		  The positional parameters from $n+1 ...  are
			  renamed $1 ....  If n is not given, it is assumed
			  to be 1.

      test		  Evaluate conditional expressions.  See test(1) for
			  usage and description.  Note that [...] in an if
			  list is interpreted the same as test ....  There
			  must be blanks around the brackets.  See also
			  test(1).



 Hewlett-Packard Company	   - 12 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      times		  Print the accumulated user and system times for
			  processes run from the shell.

      trap [arg] [n] ...  The command arg is a command to be read and
			  executed when the shell receives signal(s) n.
			  (Note that arg is scanned once when the trap is
			  set and once when the trap is taken.) Trap
			  commands are executed in order of signal number.
			  Any attempt to set a trap on a signal that was
			  ignored on entry to the current shell is
			  ineffective.	An attempt to trap on signal 11
			  (memory fault) or signal 18 (death of child)
			  produces an error.  If arg is absent then all
			  trap(s) n are reset to their original values.	 If
			  arg is the null string, this signal is ignored by
			  the shell and by the commands it invokes.  If n is
			  0, the command arg is executed on exit from the
			  shell.  The trap command with no arguments prints
			  a list of commands associated with each signal
			  number.

      type [name ...]	  For each name, indicate how it would be
			  interpreted if used as a command name.

      ulimit [-f [n]]	  If the -f n option is used, a size limit of n
			  blocks is imposed on files written by child
			  processes (files of any size can be read).  If n
			  is not specified, the current limit is printed.
			  If no option is specified, -f is assumed.

      umask [nnn]	  The user file-creation mask is set to nnn (see
			  umask(2)).  If nnn is omitted, the current value
			  of the mask is printed.  See also umask(1).

      unset [name ...]	  For each name, remove the corresponding variable
			  or function.	The variables PATH, PS1, PS2,
			  MAILCHECK, and IFS cannot be unset.

      wait [n]		  Wait for the specified process and report its
			  termination status.  If n is not given all
			  currently active child processes are waited for
			  and the return code is zero.

    Invocation
      Options can be specified in a single argument or in multiple
      arguments, but in all cases each option argument must begin with -.
      (All options except c, s, i, and r can also be prefaced with a +,
      which turns off the associated option or options, but this is
      redundant when invoking a new shell because all options are turned off
      by default).




 Hewlett-Packard Company	   - 13 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      If the first character of argument zero is -, commands are initially
      read from /etc/profile, then from $HOME/.profile, if the files exist.
      Thereafter, commands are read as described below.

      The options below are interpreted by the shell at invocation (thus
      they cannot be used with the set command).  Unless the -c or -s option
      is specified, the first non-option argument is assumed to be the name
      of a file containing commands, and the remaining arguments are passed
      as positional parameters to that command file.

	   -c string If the -c option is present then commands are read from
		     string.

	   -s	     If the -s option is present or if no arguments remain,
		     commands are read from the standard input.	 Any
		     remaining arguments specify the positional parameters.
		     Shell output (except for "Special Commands" ) is
		     written to file descriptor 2.

	   -i	     If the -i option is present or if the shell input and
		     output are attached to a terminal, this shell is
		     interactive.  In this case TERMINATE is ignored (so
		     that kill 0 does not kill an interactive shell) and
		     INTERRUPT is caught and ignored (so that wait is
		     interruptible).  In all cases, QUIT is ignored by the
		     shell.

	   -r	     If the -r option is present the shell is a restricted
		     shell.

      The remaining options and arguments are described under the set
      command above.

    rsh Only
      rsh is used to set up login names and execution environments whose
      capabilities are more controlled than those of the standard shell.
      The actions of rsh are identical to those of sh, except that the
      following are disallowed:

	   +  Changing directory (see cd(1)),
	   +  Setting the value of $PATH,
	   +  Specifying path or command names containing /,
	   +  Redirecting output (>&gt&gt&gt; and >&gt&gt&gt;>&gt&gt&gt;).

      The restrictions above are enforced after .profile is interpreted.

      When a command to be executed is found to be a shell procedure, rsh
      invokes sh to execute it.	 Thus, it is possible to provide to the
      end-user shell procedures that have access to the full power of the
      standard shell, while imposing a limited menu of commands; this scheme
      assumes that the end-user does not have write and execute permissions



 Hewlett-Packard Company	   - 14 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      in the same directory.

      The net effect of these rules is that the writer of the .profile has
      complete control over user actions, by performing guaranteed setup
      actions and leaving the user in an appropriate directory (probably not
      the login directory).

      The system administrator often sets up a directory of commands (such
      as /usr/rbin) that can be safely invoked by rsh.	Commands such as vi,
      sh, ksh, csh, and such that can break rsh restrictions should not be
      included in that directory.  Some systems also provide a restricted
      editor red.

 EXTERNAL INFLUENCES
    Environment Variables
      LC_COLLATE determines the collating sequence used in evaluating
      pattern matching notation for file name generation.

      LC_CTYPE determines the interpretation of text as single and/or
      multi-byte characters, the classification of characters as letters,
      and the characters matched by character class expressions in pattern
      matching notation.

      LANG determines the language in which messages are displayed.

      If LC_COLLATE or LC_CTYPE is not specified in the environment or is
      set to the empty string, the value of LANG is used as a default for
      each unspecified or empty variable.  If LANG is not specified or is
      set to the empty string, a default of "C" (see lang(5)) is used
      instead of LANG.	If any internationalization variable contains an
      invalid setting, sh behaves as if all internationalization variables
      are set to "C".  See environ(5).

    International Code Set Support
      Single- and multi-byte character code sets are supported.

 RETURN VALUE
      The error codes returned by the shell are:

	   0	Success.
	   1	Built-in command failure (see Special Commands).
	   2	Syntax error.
	   3	Signal received that is not trapped.

      If the shell is non-interactive, it terminates and passes one of the
      above as its exit status.	 If it is interactive, it does not
      terminate, but $? is set to one of the above values.

      Whenever a child process of the shell dies due to a signal, the shell
      returns an exit status of 80 hexadecimal plus the number of the
      signal.



 Hewlett-Packard Company	   - 15 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




 WARNINGS
      If a command is executed and a command having the same name is
      installed in a directory in the search path before the directory where
      the original command was found, the shell continues to exec the
      original command.	 Use the hash command to correct this situation.

      When the shell encounters >&gt&gt&gt;>&gt&gt&gt;, it does not open the file in append
      mode.  Instead, it opens the file for writing and seeks to the end.

      If you move the current directory or one above it, pwd cannot give the
      correct response.	 Use the cd command with a full path name to correct
      this situation.

      The command readonly (without arguments) produces the same output as
      the command export.

      Failure (non-zero exit status) of a special command preceding a ||
      symbol prevents the list following || from executing.

      In an international environment, character ordering is determined by
      the setting of LC_COLLATE, rather than by the binary ordering of
      character values in the machine collating sequence.  This brings with
      it certain attendant dangers, particularly when using range
      expressions in file-name-generation patterns.  For example, the
      command,

	   rm [a-z]*

      might be expected to match all file names beginning with a lowercase
      alphabetic character.  However, if dictionary ordering is specified by
      LC_COLLATE, it also matches file names beginning with an uppercase
      character (as well as those beginning with accented letters).
      Conversely, it fails to match letters collated after z in languages
      such as Norwegian.

      The correct (and safe) way to match specific character classes in an
      international environment is to use a pattern of the form:

	   rm [[:lower:]]*

      This uses LC_CTYPE to determine character classes and works
      predictably for all supported languages and codesets.  For shell
      scripts produced on non-internationalized systems (or without
      consideration for the above dangers), it is recommended that they be
      executed in a non-NLS environment.  This requires that LANG,
      LC_COLLATE, etc., be set to "C" or not set at all.

      sh implements command substitution by creating a pipe between itself
      and the command.	If the root file system is full, the substituted
      command cannot write to the pipe.	 As a result, the shell receives no
      input from the command, and the result of the substitution is null.



 Hewlett-Packard Company	   - 16 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      In particular, using command substitution for variable assignment
      under such circumstances results in the variable being silently
      assigned a NULL value.

      The signal SIGSEGV should not be blocked when executing sh.

      sh reserves file descriptor 59 for internal use.	Reducing the number
      of available file descriptors below 60 causes sh to fail.

      Each time a function is executed in a shell script, any arguments
      given to the function overwrite the values of the positional
      parameters for the entire script.	 If the values of the positional
      parameters must be preserved, they must be explicitly saved before
      each function call.

 AUTHOR
      sh was developed by AT&T and HP.

 FILES
      $HOME/.profile
      /dev/null
      /etc/profile
      /tmp/sh*

 SEE ALSO
      cd(1), echo(1), env(1), login(1), newgrp(1), pwd(1), read(1), test(1),
      umask(1), acctcms(1M), acctcom(1M), dup(2), exec(2), fork(2), pipe(2),
      ulimit(2), umask(2), wait(2), a.out(4), profile(4), environ(5),
      lang(5), regexp(5), signal(5).

      Bourne Shell tutorial in Shells Users Guide.

 STANDARDS CONFORMANCE
      .: SVID2, SVID3, XPG2, XPG3

      :: SVID2, SVID3, XPG2, XPG3

      break: SVID2, SVID3, XPG2, XPG3

      case: SVID2, SVID3, XPG2, XPG3

      continue: SVID2, SVID3, XPG2, XPG3

      eval: SVID2, SVID3, XPG2, XPG3

      exec: SVID2, SVID3, XPG2, XPG3

      exit: SVID2, SVID3, XPG2, XPG3

      export: SVID2, SVID3, XPG2, XPG3




 Hewlett-Packard Company	   - 17 -   HP-UX Release 11i: November 2000






 sh-bourne(1)							sh-bourne(1)




      for: SVID2, SVID3, XPG2, XPG3

      if: SVID2, SVID3, XPG2, XPG3

      read: SVID2, SVID3, XPG2, XPG3

      return: SVID2, SVID3, XPG2, XPG3

      rsh: SVID2, SVID3

      set: SVID2, SVID3, XPG2, XPG3

      sh: SVID2, SVID3, XPG2, XPG3

      shift: SVID2, SVID3, XPG2, XPG3

      time: SVID2, SVID3, XPG2, XPG3

      trap: SVID2, SVID3, XPG2, XPG3

      unset: SVID2, SVID3, XPG2, XPG3

      until: SVID2, SVID3, XPG2, XPG3

      while: SVID2, SVID3, XPG2, XPG3





























 Hewlett-Packard Company	   - 18 -   HP-UX Release 11i: November 2000