๐ system
โก system::addToPath
Add the given path to the PATH environment variable for various shells, by adding the appropriate export command to the appropriate file.
Will also export the PATH variable in the current bash.
Inputs:
$1
: path as string:the path to add to the PATH environment variable.
Example usage:
system::addToPath "/path/to/bin"
โก system::getArchitecture
Returns the CPU architecture of the current machine.
Returns:
${REPLY}
: the CPU architecture of the current machine.
Example usage:
system::getArchitecture
local architecture="${REPLY}"
โก system::getEnvVars
Get the list of all the environment variables. In pure bash, no need for env or printenv.
Returns:
${REPLY_ARRAY[@]}
: An array with the list of all the environment variables.
Example usage:
system::getEnvVars
for var in "${REPLY_ARRAY[@]}"; do
printf '%s=%s\n' "${var}" "${!var}"
done
โก system::getOs
Returns the name of the current OS.
Returns:
${REPLY}
: the name of the current OS: “darwin”, “linux” or “windows”.
Example usage:
system::getOs
local osName="${REPLY}"
โก system::isDarwin
Check if the current OS is macOS.
Returns:
$?
- 0 if the current OS is macOS
- 1 otherwise.
Example usage:
if system::isDarwin; then
printf 'The current OS is macOS.'
fi
โก system::isLinux
Check if the current OS is Linux.
Returns:
$?
- 0 if the current OS is Linux
- 1 otherwise.
Example usage:
if system::isLinux; then
printf 'The current OS is Linux.'
fi
โก system::isRoot
Check if the script is running as root.
Returns:
$?
- 0 if the script is running as root
- 1 otherwise.
Example usage:
if system::isRoot; then
printf 'The script is running as root.'
fi
โก system::isWindows
Check if the current OS is Windows.
Returns:
$?
- 0 if the current OS is Windows
- 1 otherwise.
Example usage:
if system::isWindows; then
printf 'The current OS is Windows.'
fi
Important
Documentation generated for the version 0.33.0 (2025-08-31).