ENVPATH(1)

πŸ“¦
version 0.19 Β· 4 versions
, in fedora 43

✨ 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 (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 🌟


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