logo

utils-std

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

env.1 (2129B)


  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 November 09, 2024
  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. .Oo Fl C Ar directory
  14. .Oo Fl u Ar name Oc Ns ...
  15. .Oo Ar name Ns = Ns Ar value Oc Ns ...
  16. .Op Ar command Op Ar argument...
  17. .Nm
  18. .Op Fl i
  19. .Oo Fl C Ar directory
  20. .Oo Fl u Ar name Oc Ns ...
  21. .Oo Ar name Ns = Ns Ar value Oc Ns ...
  22. .Fl S Ar command_string
  23. .Sh DESCRIPTION
  24. .Nm
  25. if specified runs
  26. .Ar command
  27. or
  28. .Ar command_string ,
  29. and otherwise prints the environment.
  30. .Pp
  31. The environment can be modified via the following options:
  32. .Bl -tag -width Ds
  33. .It Fl C Ar directory
  34. Change workding directory into
  35. .Ar directory
  36. before executing the specified command.
  37. .It Fl i
  38. Ignore the existing environment.
  39. .It Fl u Ar name
  40. Removes the variable named
  41. .Ar name
  42. from the new environment.
  43. .It Ar name Ns = Ns Ar value
  44. Adds the variable named
  45. .Ar name
  46. with the value
  47. .Ar value
  48. into the new environment, it cannot itself contain the
  49. .Qq =
  50. character.
  51. .El
  52. .Pp
  53. The
  54. .Fl S Ar command_string
  55. option allows to split a full command passed as a single argument
  56. similarly to a shell, useful for shebangs where most Unix-likes
  57. do not do argument splitting.
  58. .br
  59. For example:
  60. .Dl #!/usr/bin/env -S perl -w -T
  61. .Sh EXIT STATUS
  62. If
  63. .Ar command
  64. is invoked, the exit status of
  65. .Nm
  66. shall be the exit status of
  67. .Ar command ;
  68. Otherwise, the
  69. .Nm
  70. utility shall exit with one of the following values:
  71. .Bl -tag -width Ds
  72. .It 0
  73. .Nm
  74. completed successfully.
  75. .It 1
  76. An error occurred in
  77. .Nm
  78. .It 126
  79. .Ar command
  80. was found but couldn't be invoked.
  81. .It 127
  82. .Ar command
  83. wasn't found.
  84. .El
  85. .Sh STANDARDS
  86. .Nm
  87. should be compliant with the
  88. IEEE Std 1003.1-2024 (“POSIX.1”)
  89. specification.
  90. .Pp
  91. The
  92. .Fl u
  93. flag is an extension known to be present in
  94. .Fx ,
  95. .Nx ,
  96. .Ox 7.6 ,
  97. GNU coreutils, BusyBox, ...
  98. .br
  99. The
  100. .Fl S
  101. .\" before FreeBSD 15.0
  102. and
  103. .Fl C
  104. .\" FreeBSD 15.0
  105. flag are extensions known to be present in GNU coreutils and
  106. .Fx .
  107. .Sh AUTHORS
  108. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me