mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 15:30:40 +08:00
Define read-only $pid as %self replacement
This commit is contained in:
parent
f42f7b7208
commit
90d0f91bcd
|
@ -322,7 +322,7 @@ bool string_set_contains(const T &set, const wchar_t *val) {
|
|||
|
||||
/// Check if a variable may not be set using the set command.
|
||||
static bool is_read_only(const wchar_t *val) {
|
||||
const string_set_t env_read_only = {L"PWD", L"SHLVL", L"_", L"history", L"status", L"version"};
|
||||
const string_set_t env_read_only = {L"PWD", L"SHLVL", L"_", L"history", L"status", L"version", L"pid"};
|
||||
return string_set_contains(env_read_only, val);
|
||||
}
|
||||
|
||||
|
@ -969,6 +969,9 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
wcstring version = str2wcstring(get_fish_version());
|
||||
env_set_one(L"version", ENV_GLOBAL, version);
|
||||
|
||||
// Set the $pid variable (%self replacement)
|
||||
env_set_one(L"pid", ENV_GLOBAL, to_string<long>(getpid()));
|
||||
|
||||
// Set up SHLVL variable. Not we can't use env_get because SHLVL is read-only, and therefore was
|
||||
// not inherited from the environment.
|
||||
wcstring nshlvl_str = L"1";
|
||||
|
|
Loading…
Reference in New Issue
Block a user