env.1 (1881B)
- .\" utils-std: Collection of commonly available Unix tools
- .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- .\" SPDX-License-Identifier: MPL-2.0
- .Dd 2022-04-19
- .Dt ENV 1
- .Os
- .Sh NAME
- .Nm env
- .Nd control and print environment
- .Sh SYNOPSIS
- .Nm
- .Op Fl i
- .Op Fl u Ar name
- .Op Ar name Ns = Ns Ar value
- .Op Ar command Op Ar argument...
- .Nm
- .Op Fl i
- .Op Fl u Ar name
- .Op Ar name Ns = Ns Ar value
- .Fl S Ar command_string
- .Sh DESCRIPTION
- .Nm
- if specified runs
- .Ar command
- or
- .Ar command_string ,
- and otherwise prints the environment.
- .Pp
- The environment can be modified via the following options:
- .Bl -tag -width Ds
- .It Fl i
- Ignore the existing environment.
- .It Fl u Ar name
- Removes the variable named
- .Ar name
- from the new environment.
- .It Ar name Ns = Ns Ar value
- Adds the variable named
- .Ar name
- with the value
- .Ar value
- into the new environment, it cannot itself contain the
- .Qq =
- character.
- .El
- .Pp
- The
- .Fl S Ar command_string
- option allows to split a full command passed as a single argument
- similarly to a shell, useful for shebangs where most Unix-likes
- do not do argument splitting.
- .br
- For example:
- .Dl #!/usr/bin/env -S perl -w -T
- .Sh EXIT STATUS
- If
- .Ar command
- is invoked, the exit status of
- .Nm
- shall be the exit status of
- .Ar command ;
- Otherwise, the
- .Nm
- utility shall exit with one of the following values:
- .Bl -tag -width Ds
- .It 0
- .Nm
- completed successfully.
- .It 1
- An error occurred in
- .Nm
- .It 126
- .Ar command
- was found but couldn't be invoked.
- .It 127
- .Ar command
- wasn't found.
- .El
- .Sh STANDARDS
- .Nm
- should be compliant with the
- IEEE Std 1003.1-2024 (“POSIX.1”)
- specification.
- .Pp
- The
- .Fl u
- flag is an extension known to be present in
- .Fx ,
- .Nx ,
- .Ox 7.6 ,
- GNU coreutils, BusyBox, ...
- .br
- The
- .Fl S
- flag in an extension known to be present in GNU coreutils and
- .Fx .
- .Sh AUTHORS
- .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me