logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

env.1 (1871B)


  1. .\" utils-std: Collection of commonly available Unix tools
  2. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. .\" SPDX-License-Identifier: MPL-2.0
  4. .Dd 2022-04-19
  5. .Dt ENV 1
  6. .Os
  7. .Sh NAME
  8. .Nm env
  9. .Nd control and print environment
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Op Fl i
  13. .Op Fl u Ar name
  14. .Op Ar name Ns = Ns Ar value
  15. .Op Ar command Op Ar argument...
  16. .Nm
  17. .Op Fl i
  18. .Op Fl u Ar name
  19. .Op Ar name Ns = Ns Ar value
  20. .Fl S Ar command_string
  21. .Sh DESCRIPTION
  22. .Nm
  23. if specified runs
  24. .Ar command
  25. or
  26. .Ar command_string ,
  27. and otherwise prints the environment.
  28. .Pp
  29. The environment can be modified via the following options:
  30. .Bl -tag -width Ds
  31. .It Fl i
  32. Ignore the existing environment.
  33. .It Fl u Ar name
  34. Removes the variable named
  35. .Ar name
  36. from the new environment.
  37. .It Ar name Ns = Ns Ar value
  38. Adds the variable named
  39. .Ar name
  40. with the value
  41. .Ar value
  42. into the new environment, it cannot itself contain the
  43. .Qq =
  44. character.
  45. .El
  46. .Pp
  47. The
  48. .Fl S Ar command_string
  49. option allows to split a full command passed as a single argument
  50. similarly to a shell, useful for shebangs where most Unix-likes
  51. do not do argument splitting.
  52. .br
  53. For example:
  54. .Dl #!/usr/bin/env -S perl -w -T
  55. .Sh EXIT STATUS
  56. If
  57. .Ar command
  58. is invoked, the exit status of
  59. .Nm
  60. shall be the exit status of
  61. .Ar command ;
  62. Otherwise, the
  63. .Nm
  64. utility shall exit with one of the following values:
  65. .Bl -tag -width Ds
  66. .It 0
  67. .Nm
  68. completed successfully.
  69. .It 1
  70. An error occurred in
  71. .Nm
  72. .It 126
  73. .Ar command
  74. was found but couldn't be invoked.
  75. .It 127
  76. .Ar command
  77. wasn't found.
  78. .El
  79. .Sh STANDARDS
  80. .Nm
  81. should be compliant with the
  82. IEEE Std 1003.1-2024 (“POSIX.1”)
  83. specification.
  84. .Pp
  85. The
  86. .Fl u
  87. flag is an extension known to be present in
  88. .Fx ,
  89. .Nx ,
  90. GNU coreutils, BusyBox, ...
  91. .br
  92. The
  93. .Fl S
  94. flag in an extension known to be present in GNU coreutils and
  95. .Fx .
  96. .Sh AUTHORS
  97. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me