ENVPATH(1p)
π ENVPATH(1p) π
okay bestie so this one lives in the User Contributed Perl Documentation section of the manual, and it's literally called envpath. Let's get into it π«Ά
β¨ NAME β¨
envpath β Advanced operations on path variables π
πΈ SYNOPSIS πΈ
Run this script with the -help option for usage details. That's it, that's the whole synopsis, no cap π
π¦ DESCRIPTION π¦
So here's the vibe: envpath parses the command line, modifies the path variable(s) you specified, and then execs whatever arguments are left over. And there are two modes β simple and advanced. Pick your fighter π
β SIMPLE MODE β
Simple mode is giving platform-independent. It hands you an alternative syntax for specifying paths where the path separator is , and environment variables get expanded with @NAME@. So for example:
envpath PATH=@PATH@,/usr/ucb -- printenv PATH
this one appends "/usr/ucb" to $PATH and then execs printenv PATH. Oh and the --? Totally optional, it's just there for the aesthetic β¨
You can also specify prepending or appending 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
And the best part, the part that really ate: simple mode requires only this script. It does not require Env::Path to be installed. no dependencies, no baggage, main character energy π
π ADVANCED MODE π
Advanced mode basically provides 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 the 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. iconic behaviour fr fr π
The -Whence option allows patterns. Thus
envpath -W "cat*"
would find all programs on PATH which match cat*. slay π₯
π CLEARCASE WINKINS π
ngl a big part of the motivation for this script was for use with ClearCase builds β so iff you know or care about ClearCase, read on. π
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. π
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. Of course envpath is capable of doing more than this, but it's the original reason it was written. β¨ periodt.
π 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"
okay that's the whole page bestie, you're so welcome π«Ά this was perl v5.36.0, dated 2022-10-13, and if you ever need to cite it for your essay it's filed under ENVPATH(1p). go forth and modify those path variables ππΈπ¦
π¦ where this page comes from
- ubuntu noble: libenv-path-perl 0.19-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libenv-path-perl 0.19-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libenv-path-perl 0.19-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms