source(1) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

source(1)

exec(1)                          User Commands                         exec(1)

NAME
       exec, eval, source - shell built-in functions to execute other commands

SYNOPSIS
   /usr/sunos/bin/sh
       exec [argument]...


       eval [argument]...

   csh
       exec command


       eval argument...


       source [-h] name

   ksh88
       *exec [argument]...


       *eval [argument]...

   ksh
       +exec [-c] [-a name] [command [argument ... ]]


       +eval [argument]...

DESCRIPTION
   /usr/sunos/bin/sh
       The  exec  command  specified  by the arguments is executed in place of
       this shell without creating a new process. Input/output  arguments  and
       appear  and,  if  no other arguments are specified, cause the shell in‐
       put/output to be modified.


       The arguments to the eval built-in are read as input to the  shell  and
       the resulting command(s) executed.

   csh
       exec executes command in place of the current shell, which terminates.


       eval reads its arguments as input to the shell and executes the result‐
       ing  command(s).  This is usually used to execute commands generated as
       the result of command or variable substitution.


       source reads commands from name. source commands can be nested, but  if
       they  are  nested too deeply the shell can run out of file descriptors.
       An error in a sourced file at any level terminates  all  nested  source
       commands.

       -h    Place commands from the file name on the history list without ex‐
             ecuting them.


   ksh88
       With  the  exec built-in, if arg is specified, the command specified by
       the arguments is executed in place of this shell without creating a new
       process. Input/output arguments  can  appear  and  affect  the  current
       process. If no arguments are specified the effect of this command is to
       modify  file  descriptors as prescribed by the input/output redirection
       list. In this case, any file descriptor numbers greater than 2 that are
       opened with this mechanism are closed when invoking another program.


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


       On  this  man page, ksh88(1) commands that are preceded by one or two *
       (asterisks) are treated specially in the following ways:

           1.     Variable assignment lists preceding the  command  remain  in
                  effect when the command completes.


           2.     I/O redirections are processed after variable assignments.


           3.     Errors cause a script that contains them to abort.


           4.     Words,  following  a  command preceded by ** that are in the
                  format of a variable assignment, are expanded with the  same
                  rules  as  a variable assignment. This means that tilde sub‐
                  stitution is performed after the = sign and  word  splitting
                  and file name generation are not performed.



   ksh
       exec  is a special built-in command that can be used to manipulate file
       descriptors or to replace the current shell with a new command.


       If command is specified, then the current shell process is replaced  by
       command  rather  than  running  command and waiting for it to complete.
       There is no need to use exec to enhance performance since the shell im‐
       plicitly uses the exec mechanism internally whenever possible.


       If no operands are specified, exec can be used to open or close  files,
       or  to manipulate file descriptors from 0 to 9 in the current shell en‐
       vironment using the standard redirection mechanism available  with  all
       commands.  The  close-on-exec  flags  is set on file descriptor numbers
       greater than 2 that are opened this way so that they  are  closed  when
       another program is invoked.


       Because  exec  is a special command, any failure causes the script that
       invokes it to exit. This can be prevented by  invoking  exec  from  the
       command utility.


       exec  cannot  be  invoked from a restricted shell to create files or to
       open a file for writing or appending.


       eval is a shell special built-in command that constructs a  command  by
       concatenating the arguments together, separating each with a space. The
       resulting  string  is  taken as input to the shell and evaluated in the
       current environment. Command words are expanded  twice,  once  to  con‐
       struct argument, and again when the shell executes the constructed com‐
       mand. It is not an error if argument is not specified.


       On  this  manual  page,  ksh commands that are preceded by one or two +
       symbols are special built-in commands and are treated specially in  the
       following ways:

           1.     Variable  assignment  lists  preceding the command remain in
                  effect when the command completes.


           2.     I/O redirections are processed after variable assignments.


           3.     Errors cause a script that contains them to abort.


           4.     They are not valid function names.


           5.     Words following a command preceded by ++  that  are  in  the
                  format  of  a variable assignment are expanded with the same
                  rules as a variable assignment. This means that  tilde  sub‐
                  stitution  is performed after the = sign and field splitting
                  and file name generation are not performed.



OPTIONS
   ksh
       The following options are supported by ksh exec:

       -a name    argv[0] is set to name for command.


       -c         Clear all environment  variables  before  executions  except
                  variable  assignments that are part of the current exec com‐
                  mand.


EXIT STATUS
   ksh88
       The following exit values are returned by exec:

       0        Successful completion.


       1-125    A redirection error occurred.


       127      command was not found.


       126      command was found, but it is not an executable utility.


   ksh
       The following exit values are returned by exec. If  command  is  speci‐
       fied, exec does not return.

       0     Successful completion. All I/O redirections were successful.


       >0    An error occurred.



       The following exit values are returned by eval:


       If  argument  is  not specified, the exit status is 0. Otherwise, it is
       the exit status of the command defined by the argument operands.

ATTRIBUTES
       See the respective shell man pages for attributes of the shell built-in
       commands.

SEE ALSO
       csh(1), ksh(1), ksh88(1), sh(1s), attributes(7)

Oracle Solaris 11.4               29 Nov 2022                          exec(1)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3