autoload

Official Description

autoload is an alias for typeset -fu.

Syntax

autoload function_name
				

Options

None

Oddities

autoload enables the shell to recognize a name as a function name (-f) but not bother reading the function until it is actually needed (-u leaves the function undefined). This saves shell processing time in the event that the function is never used during the script run.

Example

 $ cat funca function funca { print "In funca" } $ $ print $FPATH $ $ pwd /home/obrien $ $ FPATH=/home/obrien # FPATH variable must include path # of file containing function $ $ autoload funca # Make ksh aware of function funca $ $ typeset –f # Not loaded yet typeset -fu funca mc() { mkdir -p ~/.mc/tmp 2> /dev/null chmod 700 ~/.mc/tmp MC=~/.mc/tmp/mc$$-"$RANDOM" ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.