userShellAliasShellPath top-level property

String? get userShellAliasShellPath

The shell used for the alias lookup, null when unsupported.

It is userShellAliasShellPathOverride when set, the SHELL environment variable (i.e. the user shell) otherwise.

bash is used when SHELL is not set (it happens when running from an IDE or a service), null is returned when the user shell is not one of userShellAliasSupportedShells (fish...). Note that the parent process is not used to detect the shell: a compiled script is often run through a sh wrapper, which would always answer sh.

Implementation

String? get userShellAliasShellPath {
  var path = userShellAliasShellPathOverride ?? platformEnvironment['SHELL'];
  if (path == null || path.isEmpty) {
    // No `SHELL` information, don't assume bash (the linux default, and available
    // on macOS too).
    return null;
  }
  if (!userShellAliasSupportedShells.contains(basename(path))) {
    return null;
  }
  return path;
}