summaryrefslogtreecommitdiff
path: root/Doc/help/autoload
blob: bc3a0294ba16501b86a70e1ac0114dbb25389c19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
autoload [ {+|-}RTUXdkmrtWz ] [ -w ] [ name ... ]
       See  the  section `Autoloading Functions' in zshmisc(1) for full
       details.  The fpath parameter will be searched to find the func-
       tion definition when the function is first referenced.

       If name consists of an absolute path, the function is defined to
       load from the file given (searching as usual for dump  files  in
       the  given  location).  The name of the function is the basename
       (non-directory part) of the file.  It is normally  an  error  if
       the function is not found in the given location; however, if the
       option -d is given,  searching  for  the  function  defaults  to
       $fpath.  If a function is loaded by absolute path, any functions
       loaded from it that are marked for autoload without an  absolute
       path  have  the  load  path  of  the parent function temporarily
       prepended to $fpath.

       If the option -r or -R is given, the function  is  searched  for
       immediately and the location is recorded internally for use when
       the function is executed; a relative path is expanded using  the
       value  of  $PWD.  This protects against a change to $fpath after
       the call to autoload.  With -r, if the function is not found, it
       is  silently  left unresolved until execution; with -R, an error
       message is printed and command  processing  aborted  immediately
       the  search  fails,  i.e. at the autoload command rather than at
       function execution..

       The flag -X may be used only inside a shell function.  It causes
       the calling function to be marked for autoloading and then imme-
       diately loaded and executed, with the  current  array  of  posi-
       tional parameters as arguments.  This replaces the previous def-
       inition of the function.  If no function definition is found, an
       error  is  printed and the function remains undefined and marked
       for autoloading.  If an argument is given, it is used as  a  di-
       rectory  (i.e.  it does not include the name of the function) in
       which the function is to be found; this may be combined with the
       -d  option  to allow the function search to default to $fpath if
       it is not in the given location.

       The flag +X attempts to load each name as  an  autoloaded  func-
       tion,  but  does  not execute it.  The exit status is zero (suc-
       cess) if the function was not previously defined and  a  defini-
       tion for it was found.  This does not replace any existing defi-
       nition of the function.  The exit status is nonzero (failure) if
       the  function  was  already  defined  or  when no definition was
       found.  In the latter case the function  remains  undefined  and
       marked  for  autoloading.   If ksh-style autoloading is enabled,
       the function created will contain the contents of the file  plus
       a call to the function itself appended to it, thus giving normal
       ksh autoloading behaviour on the first call to the function.  If
       the  -m flag is also given each name is treated as a pattern and
       all functions already marked for autoload that match the pattern
       are loaded.

       With  the  -t  flag, turn on execution tracing; with -T, turn on
       execution tracing only for the current function, turning it  off
       on  entry  to any called functions that do not also have tracing
       enabled.

       With the -U flag, alias expansion is suppressed when  the  func-
       tion is loaded.

       With the -w flag, the names are taken as names of files compiled
       with the zcompile builtin, and all functions defined in them are
       marked for autoloading.

       The flags -z and -k mark the function to be autoloaded using the
       zsh or ksh style, as if the option KSH_AUTOLOAD  were  unset  or
       were  set,  respectively.  The flags override the setting of the
       option at the time the function is loaded.

       Note that the autoload command makes no attempt  to  ensure  the
       shell  options  set  during the loading or execution of the file
       have any particular value.  For this, the emulate command can be
       used:

              emulate zsh -c 'autoload -Uz func'

       arranges that when func is loaded the shell is in native zsh em-
       ulation, and this emulation is also applied when func is run.

       Some of the functions of autoload are also provided by functions
       -u  or functions -U, but autoload is a more comprehensive inter-
       face.