Rename $pid (née %self) to $fish_pid

This commit is contained in:
Mahmoud Al-Qudsi 2018-03-15 18:31:15 -05:00
parent 0f59e42802
commit 6d80ab8d74
18 changed files with 27 additions and 27 deletions

View File

@ -12,7 +12,7 @@ This section is for changes merged to the `major` branch that are not also merge
- `for` loop control variables are no longer local to the `for` block (#1935). - `for` loop control variables are no longer local to the `for` block (#1935).
- A literal `{}` now expands to itself, rather than nothing. This makes working with `find -exec` easier. (#1109, #4632) - A literal `{}` now expands to itself, rather than nothing. This makes working with `find -exec` easier. (#1109, #4632)
- Successive commas in brace expansions are handled in less surprising manner (`{,,,}` expands to four empty strings rather than an empty string, a comma and an empty string again). (#3002, #4632). - Successive commas in brace expansions are handled in less surprising manner (`{,,,}` expands to four empty strings rather than an empty string, a comma and an empty string again). (#3002, #4632).
- `%` is no longer used for process and job expansion. `$pid` and `$last_pid` have taken the place of `%self` and `%last` respectively. (#4230, #1202) - `%` is no longer used for process and job expansion. `$fish_pid` and `$last_pid` have taken the place of `%self` and `%last` respectively. (#4230, #1202)
- The new `math` builtin (see below) does not support logical expressions; `test` should be used instead (#4777). - The new `math` builtin (see below) does not support logical expressions; `test` should be used instead (#4777).
## Notable fixes and improvements ## Notable fixes and improvements

View File

@ -2118,7 +2118,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2068,7 +2068,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2229,8 +2229,8 @@ msgstr "$? nest pas le code de retour. Dans fish, veuillez utiliser $status."
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "$$ nest pas le PID. Dans fish, veuillez utiliser $pid." msgstr "$$ nest pas le PID. Dans fish, veuillez utiliser $fish_pid."
#: src/parse_constants.h:278 #: src/parse_constants.h:278
msgid "$# is not supported. In fish, please use 'count $argv'." msgid "$# is not supported. In fish, please use 'count $argv'."

View File

@ -2027,7 +2027,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2027,7 +2027,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2051,9 +2051,9 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
"$$ nie jest numerem identyfikacyjnym procesu. W fish używane jest $pid." "$$ nie jest numerem identyfikacyjnym procesu. W fish używane jest $fish_pid."
#: src/parse_constants.h:278 #: src/parse_constants.h:278
msgid "$# is not supported. In fish, please use 'count $argv'." msgid "$# is not supported. In fish, please use 'count $argv'."

View File

@ -2084,7 +2084,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2031,7 +2031,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -2045,7 +2045,7 @@ msgstr ""
#: src/parse_constants.h:275 #: src/parse_constants.h:275
#, c-format #, c-format
msgid "$$ is not the pid. In fish, please use $pid." msgid "$$ is not the pid. In fish, please use $fish_pid."
msgstr "" msgstr ""
#: src/parse_constants.h:278 #: src/parse_constants.h:278

View File

@ -1,10 +1,10 @@
function __fish_complete_pids -d "Print a list of process identifiers along with brief descriptions" function __fish_complete_pids -d "Print a list of process identifiers along with brief descriptions"
# This may be a bit slower, but it's nice - having the tty displayed is really handy # This may be a bit slower, but it's nice - having the tty displayed is really handy
# 'tail -n +2' deletes the first line, which contains the headers # 'tail -n +2' deletes the first line, which contains the headers
# $pid is removed from output by string match -r -v # $fish_pid is removed from output by string match -r -v
# Display the tty if available # Display the tty if available
# But not if it's just question marks, meaning no tty # But not if it's just question marks, meaning no tty
ps axc -o pid,ucomm,tty | string match -r -v '^\s*'$pid'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' '' ps axc -o pid,ucomm,tty | string match -r -v '^\s*'$fish_pid'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' ''
end end

View File

@ -6,9 +6,9 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
else else
# We should never execute this block but better to be paranoid. # We should never execute this block but better to be paranoid.
if set -q TMPDIR if set -q TMPDIR
set f $TMPDIR/fish.$pid.fish set f $TMPDIR/fish.$fish_pid.fish
else else
set f /tmp/fish.$pid.fish set f /tmp/fish.$fish_pid.fish
end end
touch $f touch $f
or return 1 or return 1

View File

@ -18,11 +18,11 @@ function suspend --description 'Suspend the current shell.'
end end
if status is-interactive if status is-interactive
echo -ns 'Suspending ' $pid ': run' echo -ns 'Suspending ' $fish_pid ': run'
echo -n (set_color --bold) 'kill -CONT' $pid (set_color normal) echo -n (set_color --bold) 'kill -CONT' $fish_pid (set_color normal)
echo 'from another terminal to resume' echo 'from another terminal to resume'
end end
# XXX always causes a zombie until one fg's when we do this: # XXX always causes a zombie until one fg's when we do this:
kill -STOP $pid kill -STOP $fish_pid
end end

View File

@ -125,7 +125,7 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
{L"group", no_argument, NULL, 'g'}, {L"group", no_argument, NULL, 'g'},
{L"help", no_argument, NULL, 'h'}, {L"help", no_argument, NULL, 'h'},
{L"last", no_argument, NULL, 'l'}, {L"last", no_argument, NULL, 'l'},
{L"pid", no_argument, NULL, 'p'}, {L"fish_pid", no_argument, NULL, 'p'},
{L"quiet", no_argument, NULL, 'q'}, {L"quiet", no_argument, NULL, 'q'},
{nullptr, 0, NULL, 0}}; {nullptr, 0, NULL, 0}};

View File

@ -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. /// Check if a variable may not be set using the set command.
static bool is_read_only(const wchar_t *val) { static bool is_read_only(const wchar_t *val) {
const string_set_t env_read_only = {L"PWD", L"SHLVL", L"history", L"status", L"version", L"pid", L"hostname", L"current_cmd"}; const string_set_t env_read_only = {L"PWD", L"SHLVL", L"history", L"status", L"version", L"fish_pid", L"hostname", L"current_cmd"};
return string_set_contains(env_read_only, val); return string_set_contains(env_read_only, val);
} }
@ -956,8 +956,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
wcstring version = str2wcstring(get_fish_version()); wcstring version = str2wcstring(get_fish_version());
env_set_one(L"version", ENV_GLOBAL, version); env_set_one(L"version", ENV_GLOBAL, version);
// Set the $pid variable (%self replacement) // Set the $fish_pid variable (%self replacement)
env_set_one(L"pid", ENV_GLOBAL, to_string<long>(getpid())); env_set_one(L"fish_pid", ENV_GLOBAL, to_string<long>(getpid()));
// Set the $hostname variable // Set the $hostname variable
wcstring hostname = L"fish"; wcstring hostname = L"fish";

View File

@ -260,7 +260,7 @@ void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt);
#define ERROR_NOT_STATUS _(L"$? is not the exit status. In fish, please use $status.") #define ERROR_NOT_STATUS _(L"$? is not the exit status. In fish, please use $status.")
/// Error issued on $$. /// Error issued on $$.
#define ERROR_NOT_PID _(L"$$ is not the pid. In fish, please use $pid.") #define ERROR_NOT_PID _(L"$$ is not the pid. In fish, please use $fish_pid.")
/// Error issued on $#. /// Error issued on $#.
#define ERROR_NOT_ARGV_COUNT _(L"$# is not supported. In fish, please use 'count $argv'.") #define ERROR_NOT_ARGV_COUNT _(L"$# is not supported. In fish, please use 'count $argv'.")

View File

@ -38,7 +38,7 @@ send "exit\r"
catch {expect default exp_continue} output catch {expect default exp_continue} output
wait wait
# Verify all child processes have been killed. We don't use `-p $pid` because # Verify all child processes have been killed. We don't use `-p $fish_pid` because
# if the shell has a bug the child processes might have been reparented to pid # if the shell has a bug the child processes might have been reparented to pid
# 1 rather than killed. # 1 rather than killed.
set status [catch {exec pgrep -l -f "sleep 11"} output] set status [catch {exec pgrep -l -f "sleep 11"} output]

View File

@ -12,13 +12,13 @@ expect_prompt
send "sleep 131 &\r" send "sleep 131 &\r"
expect_prompt expect_prompt
send "sleep 132\r" send "sleep 132\r"
exec -- kill -HUP $pid exec -- kill -HUP $fish_pid
# Verify the spawned fish shell has exited. # Verify the spawned fish shell has exited.
catch {expect default exp_continue} output catch {expect default exp_continue} output
wait wait
# Verify all child processes have been killed. We don't use `-p $pid` because # Verify all child processes have been killed. We don't use `-p $fish_pid` because
# if the shell has a bug the child processes might have been reparented to pid # if the shell has a bug the child processes might have been reparented to pid
# 1 rather than killed. # 1 rather than killed.
set status [catch {exec pgrep -l -f "sleep 13"} output] set status [catch {exec pgrep -l -f "sleep 13"} output]