-
Notifications
You must be signed in to change notification settings - Fork 0
shellm.sh
-
SHELLM_TIME
: If set, shellm will measure the loading time for each library file sourced in the current process. You will then be able to print this information with the commandshellm-print-loadtime
. -
__SHELLM_LIBSTACK
: The current stack of sources being loaded. -
SHELLM_SOURCES
: The list of sources already loaded in the current shell process. -
LIBPATH
: The colon-separated list of directories in which to search for library files or packages.
-
/tmp/shellm-time.PID
: Data file used to store loading time per source for given process.
Execute a shellm command, be it a function or a script.
-
COMMAND
: The name of an existing shellm command.
-
?
: The return code of the invoked command. -
1
: Unkown command.
Locate a library file in LIBPATH.
-
FILEPATH
: The relative file path.
-
0
: File found. -
1
: File not found.
Check if LIBFILE is already in shellm sources.
-
LIBFILE
: The file absolute path.
-
0
: Source is loaded. -
1
: Source is not loaded.
Append source LIBFILE to shellm sources.
-
LIBFILE
: The file absolute path.
Append source LIBFILE to the souce stack.
-
LIBFILE
: The file absolute path.
Remove the last item of the source stack.
-
NAME
: The source name, e.g.shellm/home/lib/home.sh
.
Set the time delta sum variable to 0.
Unset the time delta sum variable.
Return a timestamp (seconds since Epoch plus nanoseconds).
Start the timer (store now
in parent local start variable).
End the timer and update the time delta sum.
Write-append the time delta for the given source in this process' data file.
-
NAME
: The source name, e.g.shellm/home/lib/home.sh
.
Pretty-print the loading time for each source for a given shell process.
-
PID
: The PID of a shell process (default to $$).
-
1
: Data file for the given PID does not exist.
- The SHELLM_TIME environment variable.
Load source if not loaded, measure load time, warn when errors.
This function first sets the time delta sum to 0. Then it checks if the given source is already loaded or not. If not, it adds it in the sources list and stack, then start the timer. It sources it, end the timer, and remove it from the stack. If something went wrong while loading it, it echoes an error with references: original script, source file, current stack.
-
NAME
: The source name, e.g.shellm/home/lib/home.sh
. -
ABS_PATH
: The library file absolute path.
-
0
: Everything OK. -
1
: Error when sourcing file.
Locate a source or package, and source it in the current shell process.
If NAME is a package, searches for every file in a lib
directory
and sources each one of them.
-
NAME
: The source or package name, e.g.shellm/home
.
-
1
: Source or package not found.
Wiki page generated with shellman.