Namespace Linux
Overview of the Bash Tools Framework functions and namespaces in the src/Linux directory
1 - Namespace src/Linux/Apt
Documentation for src/Linux/Apt directory
src/Linux/Apt
Overview
Directory src/Linux/Apt
file source src/Linux/Apt/addRepository.sh
Linux::Apt::addRepository

add apt repository followed by an apt-get update
Environment variables
Output on stdout
Requires
Features
src/Linux/Apt/install.sh
file source src/Linux/Apt/install.sh
Linux::Apt::install

apt-get install
Arguments
- … (softwares:String[]): list of softwares to install
Output on stdout
Requires
Features
src/Linux/Apt/installIfNecessary.sh
file source src/Linux/Apt/installIfNecessary.sh
Linux::Apt::installIfNecessary

apt-get install if package is not installed yet
Arguments
- … (packages:String[]): list of packages to install
Environment variables
Output on stdout
Requires
Features
src/Linux/Apt/isPackageInstalled.sh
file source src/Linux/Apt/isPackageInstalled.sh
Linux::Apt::isPackageInstalled
check if apt package is installed
Arguments
- $1 (package:String): the package name to check
Output on stdout
Requires
src/Linux/Apt/remove.sh
file source src/Linux/Apt/remove.sh
Linux::Apt::remove

remove ubuntu packages
Arguments
- … (softwares:String[]): list of softwares to remove
Output on stdout
Requires
Features
src/Linux/Apt/repositoryExists.sh
file source src/Linux/Apt/repositoryExists.sh
Linux::Apt::repositoryExists
check if apt repository is added to apt sources
Linux::requireSudoCommand
Output on stdout
Requires
src/Linux/Apt/update.sh
file source src/Linux/Apt/update.sh
Linux::Apt::update

update apt packages list
Output on stdout
Requires
Features
2 - Namespace src/Linux/Sudo
Documentation for src/Linux/Sudo directory
src/Linux/Sudo
Overview
Directory src/Linux/Sudo
file source src/Linux/Sudo/asUser.sh
Linux::Sudo::asUser
execute command passed as arguments
using sudo if current user is not already the targeted user
Arguments
- … (args:String[]): the command to execute as sudo
Environment variables
- USERNAME (String): sudo as this user (root by default)
Exit codes
Requires
- Linux::requireSudoCommand
src/Linux/Sudo/asUserInheritEnv.sh
file source src/Linux/Sudo/asUserInheritEnv.sh
Linux::Sudo::asUserInheritEnv
execute command passed as arguments
using sudo with environment inherited if current user is not already the targeted user
Arguments
- … (args:String[]): the command to execute as sudo
Environment variables
- USERNAME (String): sudo as this user (root by default)
Exit codes
- 1: exit code of sudo command
Requires
- Linux::requireSudoCommand
3 - Namespace src/Linux/Wsl
Documentation for src/Linux/Wsl directory
src/Linux/Wsl
Overview
Directory src/Linux/Wsl
file source src/Linux/Wsl/assertWindowsEtcHost.sh
Linux::Wsl::assertWindowsEtcHost
Check if Host is defined in etc/hosts of windows
Arguments
Exit codes
src/Linux/Wsl/cachedWslpath.sh
file source src/Linux/Wsl/cachedWslpath.sh
Linux::Wsl::cachedWslpath

retrieve wslpath using cache (cache is refreshed every day)
Arguments
- … (args:String[]): arguments to pass to wslpath
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
- if Linux::Wsl::originalWslpath cannot find the path
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/cachedWslpath2.sh
file source src/Linux/Wsl/cachedWslpath2.sh
Linux::Wsl::cachedWslpath2

retrieve wslpath using cache (cache is refreshed every day)
Arguments
- … (args:String[]): arguments to pass to wslpath
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
- if Linux::Wsl::originalWslpath cannot find the path
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/cachedWslpathFromWslVar.sh
file source src/Linux/Wsl/cachedWslpathFromWslVar.sh
Linux::Wsl::cachedWslpathFromWslVar

retrieve path from wslvar and then use wslpath to resolve it
using cache (cache is refreshed every day)
Arguments
- $1 (var:String): the var to retrieve using wslvar
- … (args:String[]): (optional) additional arguments to pass to wslvar
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
- if Linux::Wsl::originalWslpath cannot find the path or Linux::Wsl::originalWslvar cannot find the var
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/cachedWslpathFromWslVar2.sh
file source src/Linux/Wsl/cachedWslpathFromWslVar2.sh
Linux::Wsl::cachedWslpathFromWslVar2

retrieve path from wslvar and then use wslpath to resolve it
using cache (cache is refreshed every day)
Arguments
- $1 (var:String): the var to retrieve using wslvar
- … (args:String[]): (optional) additional arguments to pass to wslvar
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
- 1: if var cannot be found in cache nor using Linux::Wsl::originalWslvar
- 2: if path cannot be found in cache nor using Linux::Wsl::originalWslpath
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/cachedWslvar.sh
file source src/Linux/Wsl/cachedWslvar.sh
Linux::Wsl::cachedWslvar

retrieve wslvar using cache (cache is refreshed every day)
Arguments
- … (args:String[]): arguments to pass to wslvar
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslvar cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
- if Linux::Wsl::originalWslvar cannot find the variable
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/cachedWslvar2.sh
file source src/Linux/Wsl/cachedWslvar2.sh
Linux::Wsl::cachedWslvar2

retrieve wslvar using cache (cache is refreshed every day)
Arguments
- $1 (cachedWslvar2_var:&String): the variable to set by reference if the value is found
- … (args:String[]): arguments to pass to wslvar
Environment variables
- WSL_TMPDIR (String): temp directory to store the wslvar cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
- if Linux::Wsl::originalWslvar cannot find the variable
Output on stderr
- diagnostics information is displayed
Requires
Features
src/Linux/Wsl/initEnv.sh
file source src/Linux/Wsl/getKeyFromWslpathOptions.sh
Linux::Wsl::initEnv

initialize some important variables for scripts to run correctly
when wsl installation is run under wsl is in progress
Function has no arguments.
Environment variables
- WSL_INIT (int): 0 to disable wsl env initialization
Variables set
- PATH (String): populated with WINDOW_PATH paths
- WSL_INTEROP (String): with current used process
- WSL_DISTRO_NAME (String): initialized using wslpath -m /
Output on stderr
- diagnostics information is displayed
Requires
Features
Warnings
- initialization skipped if script not run under wsl
src/Linux/Wsl/originalWslpath.sh
file source src/Linux/Wsl/originalWslpath.sh
Linux::Wsl::originalWslpath
call simply original wslpath command
Arguments
- … (args:String[]): args to pass to wslpath
Exit codes
Output on stdout
Requires
src/Linux/Wsl/originalWslvar.sh
file source src/Linux/Wsl/originalWslvar.sh
Linux::Wsl::originalWslvar
call simply original wslvar command
Arguments
- … (args:String[]): args to pass to wslvar
Exit codes
Output on stdout
Requires
src/Linux/Wsl/requireWsl.sh
file source src/Linux/Wsl/requireWsl.sh
Linux::Wsl::requireWsl
ensure linux runs under wsl
Environment variables
- WSL_GARBAGE_COLLECT (int): 0 to disable garbage collect of cache files
Exit codes
- 1: if linux does not run under wsl