Env
Template:Short description
Template:Lowercase title
Template:About
{{#invoke:Infobox|infobox}}Template:Template other {{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y| AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo class | logo size | logo title | logo upright | logo_alt | logo_caption | logo_class | logo_size | logo_title | logo_upright | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | qid | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot class | screenshot size | screenshot title | screenshot upright | screenshot_alt | screenshot_class | screenshot_size | screenshot_upright | service_name | size | standard | title | ver layout | website }}Template:Main other{{#invoke:Check for conflicting parameters|check
| template = Template:Infobox software
| cat = Template:Main other
| logo size; logo_size
| logo class; logo_class
| logo alt; logo_alt
| logo title; logo_title
| logo caption; logo_caption
| screenshot size; screenshot_size
| screenshot upright; screenshot_upright
| screenshot class; screenshot_class
| screenshot alt; screenshot_alt
| screenshot title; screenshot title
| latest release version; latest_release_version
| latest release date; latest_release_date
| latest preview version; latest_preview_version
| latest preview date; latest_preview_date
| latest release version; latest_release_version
| latest release date; latest_release_date
| latest preview version; latest_preview_version
| latest preview date; latest_preview_date
| programming language; programming_language
| operating system; operating_system
}}
env is a shell command that either reports environment variables or runs a command in a subprocess with modified environment variables. The command is provided in a Unix-like system.
By default, a subprocess inherits the environment variables of the parent process. env supports adding, modifying and removing the copied variables. env can also be used to launch the correct interpreter.Template:Clarify In this usage, the environment is typically not changed. The command does not modify environment variables in the process in which it runs. Mechanisms for doing so include the <syntaxhighlight lang="text" class="" style="" inline="1">export</syntaxhighlight> command and assigning a name to a value like <syntaxhighlight lang="text" class="" style="" inline="1">NAME=value</syntaxhighlight>.
The GNU coreutils version was written by Richard Mlynarik, David MacKenzie, and Assaf Gordon.[1] It first appeared in 4.4BSD, and is a part of POSIX.1 (with the Template:Tt option only).[2] This version has been extended to handle signals and the current directory.[1]
FreeBSD's version supports a custom search path. Extensions found in both versions include Template:Tt, for unsetting variables, and Template:Tt, for splitting arguments (mainly in shebang).[2]
Examples
The following command line prints the current environment variables to standard output: <syntaxhighlight lang="bash"> $ env </syntaxhighlight>
The following command line creates a new shell without any environment variables: <syntaxhighlight lang="bash"> $ env -i /bin/sh </syntaxhighlight>
The following command line executes the application xcalc such that the variable DISPLAY has value "foo.bar:1.0" so that it shows on the specified display: <syntaxhighlight lang="bash"> $ env DISPLAY=foo.bar:1.0 xcalc </syntaxhighlight>
This use of env is often unnecessary since most shells support setting environment variables in front of a command like: <syntaxhighlight lang="bash"> $ DISPLAY=foo.bar:1.0 xcalc </syntaxhighlight>
env may also be used in the hashbang line of a script to allow the interpreter to be looked up via the PATH. For example, here is the code of a Python script: <syntaxhighlight lang="bash">
- !/usr/bin/env python3
print("Hello, World!") </syntaxhighlight>
In this example, /usr/bin/env is the full path of the env command. The environment is not altered.
Note that it is possible to specify the interpreter without using env, by giving the full path of the python interpreter. A problem with that approach is that on different computer systems, the exact path may be different. By instead using env as in the example, the interpreter is searched for and located at the time the script is run (more precisely, env does a system call to execvp, which does the job of locating the interpreter and launching it). This makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches for a match in every directory on the executable search path. It also suffers from the same problem in that the path to the env binary may also be different on a per-machine basis.
See also
{{#invoke:Portal|portal}}
References
External links
- Template:Man
- Template:Man
- env—manual page from GNU coreutils.
- Template:Man
- Template:Man
- Template:Man
- Template:Man
- Template:Man
Template:Unix commands Template:Core Utilities commands
- ↑ 1.0 1.1 Template:Man
- ↑ 2.0 2.1 Template:Man