manpagez: man pages & more
man set(1)
Home | html | info | man
set(1)                               fish                               set(1)




NAME

       set - handle environment variables.


   Synopsis
       set [SCOPE_OPTIONS]
       set [OPTIONS] VARIABLE_NAME VALUES...
       set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES...
       set (-q | --query) [SCOPE_OPTIONS] VARIABLE_NAMES...
       set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME
       set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...


       The set builtin causes fish to assign the variable VARIABLE_NAME the
       values VALUES....

   Description
       o -e or --erase causes the specified environment variable to be erased

       o -l or --local forces the specified environment variable to be given a
         scope that is local to the current block, even if a variable with the
         given name exists and is non-local

       o -g or --global causes the specified environment variable to be given
         a global scope. Non-global variables disappear when the block they
         belong to ends

       o -U or --universal causes the specified environment variable to be
         given a universal scope. If this option is supplied, the variable
         will be shared between all the current users fish instances on the
         current computer, and will be preserved across restarts of the shell.

       o -n or --names List only the names of all defined variables, not their
         value

       o -q or --query test if the specified variable names are defined. Does
         not output anything, but the builtins exit status is the number of
         variables specified that were not defined.

       o -u or --unexport causes the specified environment not to be exported
         to child processes

       o -x or --export causes the specified environment variable to be
         exported to child processes


       If set is called with no arguments, the names and values of all
       environment variables are printed. If some of the scope or export flags
       have been given, only the variables matching the specified scope are
       printed.

       If a variable is set to more than one value, the variable will be an
       array with the specified elements. If a variable is set to zero
       elements, it will become an array with zero elements.

       If the variable name is one or more array elements, such as PATH[1 3
       7], only those array elements specified will be changed. When array
       indices are specified to set, multiple arguments may be used to specify
       additional indexes, e.g. set PATH[1] PATH[4] /bin /sbin. If you specify
       a negative index when expanding or assigning to an array variable, the
       index will be calculated from the end of the array. For example, the
       index -1 means the last index of an array.

       The scoping rules when creating or updating a variable are:


       1.  If a variable is explicitly set to either universal, global or
           local, that setting will be honored. If a variable of the same name
           exists in a different scope, that variable will not be changed.

       2.  If a variable is not explicitly set to be either universal, global
           or local, but has been previously defined, the previous variable
           scope is used.

       3.  If a variable is not explicitly set to be either universal, global
           or local and has never before been defined, the variable will be
           local to the currently executing functions. If no function is
           executing, the variable will be global.


       The exporting rules when creating or updating a variable are identical
       to the scoping rules for variables:


       1.  If a variable is explicitly set to either be exported or not
           exported, that setting will be honored.

       2.  If a variable is not explicitly set to be exported or not exported,
           but has been previously defined, the previous exporting rule for
           the variable is kept.

       3.  If a variable is not explicitly set to be either exported or
           unexported and has never before been defined, the variable will not
           be exported.


       In query mode, the scope to be examined can be specified.

       In erase mode, if variable indices are specified, only the specified
       slices of the array variable will be erased. When erasing an entire
       variable (i.e. no slicing), the scope of the variable to be erased can
       be specified. That way, a global variable can be erased even if a local
       variable with the same name exists. Scope can not be specified when
       erasing a slice of an array. The innermost scope is always used.

       The set command requires all switch arguments to come before any non-
       switch arguments. For example, set flags -l will have the effect of
       setting the value of the variable flags to '-l', not making the
       variable local.

       In assignment mode, set exits with an exit status of zero it the
       variable assignments where sucessfully performed, with a non-zero exit
       status otherwise. In query mode, the exit status is the number of
       variables that where not found. In erase mode, set exits with a zero
       exit status in case of success, with a non-zero exit status if the
       commandline was invalid, if the variable was write-protected or if the
       variable did not exist.

   Example
       set -xg will print all global, exported variables.

       set foo hi sets the value of the variable foo to be hi.

       set -e smurf removes the variable smurf.

       set PATH[4] ~/bin changes the fourth element of the PATH array to ~/bin



Version 1.23.1                    8 Mar 2009                            set(1)

fish 1.23.1 - Generated Sun Mar 8 14:17:45 CDT 2009
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.