OSH(1)                           User Commands                          OSH(1)

       osh - old shell (command interpreter)

       osh [ -c command ] [ -t ] [ file [ arg1 ... [ arg9 ] ] ]

       Osh is a reimplementation of the standard command interpreter from
       Sixth Edition UNIX which was also distributed as osh with Seventh
       Edition UNIX.  It may be used interactively to read and execute command
       lines typed by users.  It may also be used non-interactively to
       interpret and execute command files.  The command language is a sparse
       subset of that found in modern shells and is mostly common to both
       sh(1) and csh(1).

       The options are as follows:

       -c command
              Execute command and exit.

       -t     Read a single line from standard input, execute it as a command,
              and exit.

       Each command is a sequence of non-blank command arguments separated by
       blanks (spaces or tabs).  The first argument specifies the name of a
       command to be executed.  Except for certain types of special arguments
       discussed below, the arguments other than the command name are passed
       without interpretation to the invoked command.

       The command name is used to locate the command by searching the
       sequence of directories in the environment variable PATH.  If the
       command cannot be found, or cannot be executed, a diagnostic is

   Command lines
       One or more commands separated by `|' or `^' constitute a chain of
       filters.  The standard output of each command but the last is taken as
       the standard input of the next command.  Each command is run as a
       separate process, connected by pipes (see pipe(2)) to its neighbors.  A
       command line contained in parentheses `( )' is executed in a subshell
       and may appear in place of a simple command as a filter.

       A command line consists of one or more pipelines separated, and perhaps
       terminated by `;' or `&'.  The semicolon designates sequential
       execution.  The ampersand designates asynchronous execution which
       causes the preceding pipeline to be executed without waiting for it to
       finish.  The process ID of such a pipeline is reported, so that it may
       be used if necessary for a subsequent kill.

   Termination reporting
       If a command (not followed by `&') terminates abnormally, a message is
       printed.  (All terminations other than exit and interrupt are
       considered abnormal.)  Termination reports for commands followed by `&'
       are given upon receipt of the first command subsequent to its
       termination, or when a wait is executed.  The following is a list of
       the abnormal termination messages:

            Illegal instruction
            Trace/BPT trap
            IOT trap
            EMT trap
            Floating exception
            Bus error
            Memory fault
            Bad system call
            Broken pipe

       If a core image is produced, `-- Core dumped' is appended to the
       appropriate message.

   I/O redirection
       There are three character sequences that cause the immediately
       following string to be interpreted as a special argument to the shell
       itself.  Such an argument may appear anywhere among the arguments of a
       simple command, or before or after a parenthesized command list, and is
       associated with that command or command list.

       An argument of the form `<arg' causes the file `arg' to be used as the
       standard input (file descriptor 0) for the associated command.

       An argument of the form `>arg' causes the file `arg' to be used as the
       standard output (file descriptor 1) for the associated command.  `Arg'
       is created if it did not exist, and in any case is truncated at the

       An argument of the form `>>arg' causes the file `arg' to be used as the
       standard output for the associated command.  If `arg' did not exist, it
       is created; if it did exist, the command output is appended to the

       For example, either of the command lines

            date >/tmp/list; ls -l >>/tmp/list
            ( date; ls -l ) >/tmp/list

       creates, on file `/tmp/list', the current date and time, followed
       immediately by a long listing of the current directory.

       Either of the constructs `>arg' or `>>arg' associated with any but the
       last command of a pipeline is ineffectual, as is `<arg' in any but the

       In commands called by the shell, file descriptor 2 refers to the
       standard error.  Thus, commands may write diagnostics to a location
       where they have a chance to be seen.

   File name generation
       If any argument contains unquoted `*', `?', or `[' characters, it is
       treated specially as follows.  The current directory is searched for
       files which match the given argument.  If no file name matches the
       argument, it is left unchanged.  The directory entries . and .., and
       the / character, are normally excluded from matches and must be matched

       The character `*' in an argument matches any string of characters in a
       file name (including the null string).

       The character `?' matches any single character in a file name.

       Square brackets `[...]' specify a class of characters which matches any
       single file-name character in the class.  Within the brackets, each
       ordinary character is taken to be a member of the class.  A pair of
       characters separated by `-' places in the class each character
       lexically greater than or equal to the first and less than or equal to
       the second member of the pair.

       Other characters match only the same character in the file name.

       For example, `*' matches all file names; `?' matches all one-character
       file names; `[ab]*.s' matches all file names beginning with `a' or `b'
       and ending with `.s'; `?[zi-m]' matches all two-character file names
       ending with `z' or the letters `i' through `m'.

       If the argument with `*', `?', or `[' also contains a `/', a slightly
       different procedure is used:  instead of the current directory, the
       directory used is the one obtained by taking the argument up to the
       last `/' before a `*', `?', or `['.  The matching process matches the
       remainder of the argument after this `/' against the files in the
       derived directory.  For example:  `/usr/dmr/a*.s' matches all files in
       directory `/usr/dmr' which begin with `a' and end with `.s'.

       In any event, a list of names is obtained which match the argument.
       This list is sorted into alphabetical order, and the resulting sequence
       of arguments replaces the single argument containing the `*', `?', or
       `['.  The same process is carried out for each argument (the resulting
       lists are not merged) and finally the command is called with the
       resulting list of arguments.

       The character `\' causes the immediately following character to lose
       any special meaning it may have to the shell; in this way `<', `>', and
       other characters meaningful to the shell may be passed as part of
       arguments.  A special case of this feature allows the continuation of
       commands onto more than one line:  a new-line preceded by `\' is
       translated into a blank.

       Sequences of characters enclosed in double (") or single (') quotes are
       also taken literally.  For example:

            sed "/^$/d" My_File ^ more

       causes sed to delete blank lines from `My_File' and pipe the output to
       more for viewing.  Quotes prevent the shell from trying to interpret
       the `^' as a pipe and the `$' as the beginning of a parameter.

   Parameter substitution
       When the shell is used non-interactively to execute a command file, it
       has additional string processing capabilities.  Recall that the shell
       can be invoked as follows.

            osh [ file [ arg1 ... [ arg9 ] ] ]

       In this case, file is the name of a file which is read and interpreted.
       If not given, this instance of the shell is interactive and continues
       to read from standard input.

       In command lines in the file (not in command input), unquoted character
       sequences of the form `$n', where n is a digit, are replaced by the nth
       argument to the invocation of the shell (argn).  `$0' is replaced by

   End of file
       An end-of-file in the shell's input causes it to exit.  If interactive,
       this means the shell terminates when the user types an EOF (often
       represented by `^D') at the beginning of a line.

   Special commands
       The following commands are normally treated specially by the shell but
       only when not quoted.  Attempts to pipe or redirect these commands have
       no effect.

       chdir  [ dir ]
              changes the shell's working directory to dir.  In the absence of
              the dir argument, the user's home directory is used as the
              default argument.  If dir is `-', the previous working directory
              is used instead.  These are enhancements to chdir which were not
              available in the original Sixth Edition UNIX shell.

       exit   terminates command file.

       login  login(1) is executed in interactive shells without creating a
              new process.

       shift  shifts all positional parameters to the left by 1 with the
              exception of `$0' which remains constant.

       wait   waits for all asynchronous processes.

       :      is simply ignored and always returns zero.

   Command file errors; interrupts
       Any shell-detected error, or an interrupt signal, during the execution
       of a command file causes the shell to cease execution of that file.

       Processes that are created with `&' ignore interrupts.  Also if such a
       process has not redirected its input with a `<', its input is
       automatically redirected from the zero length file /dev/null.

       HOME   Is the default argument (home directory) for the chdir command.

       PATH   Is used as the search path for external commands.  The original
              Sixth Edition UNIX shell always used `.:/bin:/usr/bin', not

              source of input for asynchronous commands

       `The UNIX Time-Sharing System', CACM, July, 1974, which gives the
       theory of operation of the shell.
       csh(1), env(1), goto(1), if(1), login(1), sh(1)

       There is no way to redirect the diagnostic output.

Ancient Unix Ports             February 12, 2004                        OSH(1)