Merge branch 'master' into major

This commit is contained in:
Kurtis Rader 2017-08-10 17:00:56 -07:00
commit 3f999209a5
3 changed files with 47 additions and 14 deletions

View file

@ -14,7 +14,7 @@
- <a href='#faq-subcommand'>How do I run a subcommand? The backtick doesn't work!</a> - <a href='#faq-subcommand'>How do I run a subcommand? The backtick doesn't work!</a>
- <a href='#faq-exit-status'>How do I get the exit status of a command?</a> - <a href='#faq-exit-status'>How do I get the exit status of a command?</a>
- <a href='#faq-single-env'>How do I set an environment variable for just one command?</a> - <a href='#faq-single-env'>How do I set an environment variable for just one command?</a>
- <a href='#faq-exported-uvar'>Why doesn't `set -Ux` (exported universal vars) seem to work?</a> - <a href='#faq-exported-uvar'>Why doesn't `set -Ux` (exported universal varables) seem to work?</a>
- <a href='#faq-customize-colors'>How do I customize my syntax highlighting colors?</a> - <a href='#faq-customize-colors'>How do I customize my syntax highlighting colors?</a>
- <a href='#faq-update-manpage-completions'>How do I update man page completions?</a> - <a href='#faq-update-manpage-completions'>How do I update man page completions?</a>
- <a href='#faq-cwd-symlink'>Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?</a> - <a href='#faq-cwd-symlink'>Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?</a>
@ -126,19 +126,27 @@ begin
end end
\endfish \endfish
\section faq-exported-uvar Why doesn't `set -Ux` (exported universal vars) seem to work? \section faq-exported-uvar Why doesn't `set -Ux` (exported universal variables) seem to work?
Lots of users try to set exported environment variables like `EDITOR` and `TZ` as universal variables; e.g., `set -Ux`. That works but the behavior can be surprising. Keep in mind that when resolving a variable reference (e.g., `echo $EDITOR`) fish first looks in local scope, then global scope, and finally universal scope. Also keep in mind that environment vars imported when fish starts running are placed in the global scope. So if `EDITOR` or `TZ` is already in the environment when fish starts running your universal var by the same name is not used. A global variable of the same name already exists.
The recommended practice is to not export universal variables in the hope they will be present in all future shells. Instead place statements like the following example in your config.fish file: Environment variables such as `EDITOR` or `TZ` can be set universally using `set -Ux`. However, if
there is an environment variable already set before fish starts (such as by login scripts or system
administrators), it is imported into fish as a global variable. The <a
href="index.html#variables-scope">variable scopes</a> are searched from the "inside out", which
means that local variables are checked first, followed by global variables, and finally universal
variables.
This means that the global value takes precedence over the universal value.
To avoid this problem, consider changing the setting which fish inherits. If this is not possible,
add a statement to your <a href="index.html#">user initilization file</a> (usually
`~/.config/fish/config.fish`):
\fish{cli-dark} \fish{cli-dark}
set -q EDITOR set -gx EDITOR vim
or set -gx EDITOR vim
\endfish \endfish
Now when fish starts it will use the existing value for the variable if it was in the environment. Otherwise it will be set to your preferred default. This allows programs like emacs or an IDE to start a fish shell with a different value for the var. This is effectively the same behavior seen when setting it as a uvar but is explicit and therefore easier to reason about and debug. If you don't want to allow using the existing environment value just unconditionally `set -gx` the var in your config.fish file.
\section faq-customize-colors How do I customize my syntax highlighting colors? \section faq-customize-colors How do I customize my syntax highlighting colors?
Use the web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, or alter the <a href="index.html#variables-color">`fish_color` family of environment variables</a>. Use the web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, or alter the <a href="index.html#variables-color">`fish_color` family of environment variables</a>.

View file

@ -2178,6 +2178,21 @@ bool shell_is_exiting() {
return end_loop; return end_loop;
} }
static void bg_job_warning() {
fputws(_(L"There are still jobs active:\n"), stdout);
fputws(_(L"\n PID Command\n"), stdout);
job_iterator_t jobs;
while (job_t *j = jobs.next()) {
if (!job_is_completed(j)) {
fwprintf(stdout, L"%6d %ls\n", j->pgid, j->command_wcstr());
}
}
fputws(L"\n", stdout);
fputws(_(L"Use `disown PID` to let them live independently from fish.\n"), stdout);
fputws(_(L"A second attempt to exit will terminate them.\n"), stdout);
}
/// This function is called when the main loop notices that end_loop has been set while in /// This function is called when the main loop notices that end_loop has been set while in
/// interactive mode. It checks if it is ok to exit. /// interactive mode. It checks if it is ok to exit.
static void handle_end_loop() { static void handle_end_loop() {
@ -2202,8 +2217,7 @@ static void handle_end_loop() {
} }
if (!data->prev_end_loop && bg_jobs) { if (!data->prev_end_loop && bg_jobs) {
fputws(_(L"There are still jobs active (use the jobs command to see them).\n"), stdout); bg_job_warning();
fputws(_(L"A second attempt to exit will terminate them.\n"), stdout);
reader_exit(0, 0); reader_exit(0, 0);
data->prev_end_loop = 1; data->prev_end_loop = 1;
return; return;

View file

@ -9,8 +9,13 @@ expect_prompt
send "sleep 111 &\r" send "sleep 111 &\r"
expect_prompt expect_prompt
send "exit\r" send "exit\r"
expect "There are still jobs active" expect -re "There are still jobs active:\r
expect "A second attempt to exit will terminate them." \r
PID Command\r
*\\d+ sleep 111 &\r
\r
Use `disown PID` to let them live independently from fish.\r
A second attempt to exit will terminate them.\r"
expect_prompt expect_prompt
# Running anything other than `exit` should result in the same warning with # Running anything other than `exit` should result in the same warning with
@ -18,8 +23,14 @@ expect_prompt
send "sleep 113 &\r" send "sleep 113 &\r"
expect_prompt expect_prompt
send "exit\r" send "exit\r"
expect "There are still jobs active" expect -re "There are still jobs active:\r
expect "A second attempt to exit will terminate them." \r
PID Command\r
*\\d+ sleep 113 &\r
*\\d+ sleep 111 &\r
\r
Use `disown PID` to let them live independently from fish.\r
A second attempt to exit will terminate them.\r"
expect_prompt expect_prompt
# Verify that asking to exit a second time does so. # Verify that asking to exit a second time does so.