ENVPATH(1)
β¨ ENVPATH(1) β¨
okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's about a little script called envpath. Buckle up, it's giving path-variable glow-up π
π NAME π
envpath β advanced operations on path variables. yes, advanced. we're not just appending here, we're doing choreography π©°
πΈ SYNOPSIS πΈ
Run this script with the -help option for usage details. that's it, that's the synopsis, she's lowkey mysterious β¨
π¦ DESCRIPTION π¦
So here's the vibe: it parses the command line, modifies the path variable(s) you told it to modify, and then execs whatever arguments are left over. Two modes, bestie: simple and advanced. pick your fighter π₯
π SIMPLE MODE π
Simple mode is the platform-independent girlie. She lets you specify paths with a syntax that works everywhere, where the path separator is , (a comma, not a colon, not a semicolon, a comma) and environment variables get expanded with @NAME@. Obsessed.
Like, for example:
envpath PATH=@PATH@,/usr/ucb -- printenv PATH
That appends /usr/ucb to $PATH and execs printenv PATH. and the --? totally optional, it's just there for the aesthetic π«Ά
You can also prepend or append by using += or =+ respectively:
# place /usr/ucb at the front
envpath PATH+=/usr/ucb -- printenv PATH
# place /usr/ucb at the back
envpath PATH=+/usr/ucb -- printenv PATH
Simple mode requires only this script. It does not require Env::Path to be installed. she's self-sufficient, she doesn't need anybody π
π ADVANCED MODE π
Advanced mode is basically command-line access to the features of Env::Path (see), which β heads up β must be installed. The -E flag selects the path variable to operate on, and other flags specify operations on it. E.g.
envpath -E MANPATH -A /tmp -R /usr/share/man -N -U -- man ...
would take MANPATH, append /tmp to it, remove any references to "/usr/share/man", remove any dirs which don't exist (-N) and remove redundant entries (-U) before running man. that's a whole spa day for your MANPATH, no cap π§
The -Whence option allows patterns. Thus:
envpath -W "cat*"
would find all programs on PATH which match cat*. she's searching, she's thorough, she ate π₯
π CLEARCASE WINKINS π
okay so a big part of the motivation for this script was for use with ClearCase builds; iff you know or care about ClearCase read on. (that's "iff" with two f's bestie, we're being precise π)
Typically, during builds (and not just with ClearCase), pathvars such as PATH, CLASSPATH, and LD_LIBRARY_PATH must be strictly controlled. One choice is to force static values of these into the environment during the build process, another is to simply require/expect users to set their paths appropriately. Each of these can lead to subtle build or runtime errors, however, and makes it hard for new users to get up to speed since their personal environment must be just so. π the struggle is real
Another common choice is to use only full pathnames within the Makefile, avoiding reliance on search paths at all. This is often the best way to go but can suppress ClearCase winkins. For example, say you're generating ascii files of some type with a binary executable you just built:
$(INCDIR)/foo.h: $(BINDIR)/foomaker $(BINDIR)/foomaker ...
The problem with this is that $(BINDIR) likely contains a platform part such as 'solaris' or 'hpux', which makes it impossible to wink in the foo.h file on other platforms even though it's ascii. This same thing could come up even with a standard pre-built utility that's in different places on different platforms; "yacc", for instance, is in /usr/bin on Linux and /usr/ccs/bin on Solaris. π
You could modify the path on the fly:
$(INCDIR)/foo.h: $(BINDIR)/foomaker PATH=$(BINDIR)$(SEP)$$PATH
foomaker ...
but this suffers from the same problem: since $(BINDIR) and $PATH are expanded literally within the build script they'll suppress winkins. π
Here's a solution using envpath:
$(INCDIR)/foo.h: $(BINDIR)/foomaker envpath PATH=@BINDIR@,@PATH@
foomaker ...
This hides the evaluation of BINDIR and PATH such that clearmake never sees anything but the literals, thus clearing the field for winkins. iconic behavior honestly β¨
Of course envpath is capable of doing more than this, but it's the original reason it was written. the origin story, if you will π
π AUTHOR π
David Boyce <dsbperl AT boyski.com>
π COPYRIGHT π
Copyright (c) 2000-2001 David Boyce. All rights reserved.
This Perl program is free software; you may redistribute and/or modify it under the same terms as Perl itself.
π SEE ALSO π
perl(1)"perldoc Env::Path"
and that's the whole page bestie!! π«Ά this one's from perl v5.42.0, dated 2025-07-25, and it lives in the ENVPATH(1) section of your friendly neighbourhood manual. go forth and wrangle those path variables, you absolute legend ππ
π¦ where this page comes from
- fedora 43: perl-Env-Path 0.19-33.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms