mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
slave: unset TERM_PROGRAM{,_VERSION}
Foot’s policy is to not set environment variables that identifies it (except the well-known and established `TERM` variable). We encourage applications to use terminfo to determine capabilities, or terminal queries, when available. Or, at least use terminal queries to detect the terminal and its version. Setting environment variables is a bad idea since they are inherited by all applications started by the terminal (which is the whole point). But, this includes other terminal emulators, making it very possible a terminal emulator gets mis-detected just because it was started from another terminal. Since there are a couple of terminal emulators that _do_ set TERM_PROGRAM and TERM_PROGRAM_VERSION, unset these environment variables to avoid being misdetected. Closes #1349
This commit is contained in:
parent
d2f81443f1
commit
a2f765b72a
5 changed files with 4 additions and 27 deletions
|
|
@ -93,7 +93,7 @@
|
||||||
* “Report DA2” terminfo entries (`RV`/`rv`).
|
* “Report DA2” terminfo entries (`RV`/`rv`).
|
||||||
* `XF` terminfo capability (focus in/out events available).
|
* `XF` terminfo capability (focus in/out events available).
|
||||||
* `$TERM_PROGRAM` and `$TERM_PROGRAM_VERSION` environment variables
|
* `$TERM_PROGRAM` and `$TERM_PROGRAM_VERSION` environment variables
|
||||||
set in the slave process.
|
unset in the slave process.
|
||||||
|
|
||||||
[1136]: https://codeberg.org/dnkl/foot/issues/1136
|
[1136]: https://codeberg.org/dnkl/foot/issues/1136
|
||||||
[1225]: https://codeberg.org/dnkl/foot/issues/1225
|
[1225]: https://codeberg.org/dnkl/foot/issues/1225
|
||||||
|
|
|
||||||
|
|
@ -546,17 +546,6 @@ In all other cases, the exit code is that of the client application
|
||||||
This variable is set to *truecolor*, to indicate to client
|
This variable is set to *truecolor*, to indicate to client
|
||||||
applications that 24-bit RGB colors are supported.
|
applications that 24-bit RGB colors are supported.
|
||||||
|
|
||||||
*TERM_PROGRAM*
|
|
||||||
Always set to *foot*. This can be used by client applications to
|
|
||||||
check which terminal is in use, but with the caveat that it may
|
|
||||||
have been inherited from a parent process in other terminals that
|
|
||||||
aren't known to set the variable.
|
|
||||||
|
|
||||||
*TERM_PROGRAM_VERSION*
|
|
||||||
Set to the foot version string, in the format _major_*.*_minor_*.*_patch_
|
|
||||||
or _major_*.*_minor_*.*_patch_*-*_revision_*-\g*_commit_ for inter-release
|
|
||||||
builds. The same caveat as for *TERM_PROGRAM* applies.
|
|
||||||
|
|
||||||
In addition to the variables listed above, custom environment
|
In addition to the variables listed above, custom environment
|
||||||
variables may be defined in *foot.ini*(5).
|
variables may be defined in *foot.ini*(5).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,17 +158,6 @@ terminfo entries manually, by copying *foot* and *foot-direct* to
|
||||||
This variable is set to *truecolor*, to indicate to client
|
This variable is set to *truecolor*, to indicate to client
|
||||||
applications that 24-bit RGB colors are supported.
|
applications that 24-bit RGB colors are supported.
|
||||||
|
|
||||||
*TERM_PROGRAM*
|
|
||||||
Always set to *foot*. This can be used by client applications to
|
|
||||||
check which terminal is in use, but with the caveat that it may
|
|
||||||
have been inherited from a parent process in other terminals that
|
|
||||||
aren't known to set the variable.
|
|
||||||
|
|
||||||
*TERM_PROGRAM_VERSION*
|
|
||||||
Set to the foot version string, in the format _major_*.*_minor_*.*_patch_
|
|
||||||
or _major_*.*_minor_*.*_patch_*-*_revision_*-\g*_commit_ for inter-release
|
|
||||||
builds. The same caveat as for *TERM_PROGRAM* applies.
|
|
||||||
|
|
||||||
In addition to the variables listed above, custom environment
|
In addition to the variables listed above, custom environment
|
||||||
variables may be defined in *foot.ini*(5).
|
variables may be defined in *foot.ini*(5).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ patch=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/')
|
||||||
extra=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?.*/\5/')
|
extra=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?.*/\5/')
|
||||||
|
|
||||||
new_version="#define FOOT_VERSION \"${new_version}\"
|
new_version="#define FOOT_VERSION \"${new_version}\"
|
||||||
#define FOOT_VERSION_SHORT \"${git_version:-${default_version}}\"
|
|
||||||
#define FOOT_MAJOR ${major}
|
#define FOOT_MAJOR ${major}
|
||||||
#define FOOT_MINOR ${minor}
|
#define FOOT_MINOR ${minor}
|
||||||
#define FOOT_PATCH ${patch}
|
#define FOOT_PATCH ${patch}
|
||||||
|
|
|
||||||
6
slave.c
6
slave.c
|
|
@ -21,7 +21,6 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "version.h"
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
@ -352,11 +351,12 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("TERM", term_env, 1);
|
setenv("TERM", term_env, 1);
|
||||||
setenv("TERM_PROGRAM", "foot", 1);
|
|
||||||
setenv("TERM_PROGRAM_VERSION", FOOT_VERSION_SHORT, 1);
|
|
||||||
setenv("COLORTERM", "truecolor", 1);
|
setenv("COLORTERM", "truecolor", 1);
|
||||||
setenv("PWD", cwd, 1);
|
setenv("PWD", cwd, 1);
|
||||||
|
|
||||||
|
unsetenv("TERM_PROGRAM");
|
||||||
|
unsetenv("TERM_PROGRAM_VERSION");
|
||||||
|
|
||||||
#if defined(FOOT_TERMINFO_PATH)
|
#if defined(FOOT_TERMINFO_PATH)
|
||||||
setenv("TERMINFO", FOOT_TERMINFO_PATH, 1);
|
setenv("TERMINFO", FOOT_TERMINFO_PATH, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue