[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Intend to package (maybe)



While scanning through the sources I have on my machine I found a nice
little tool to make chnes to the PATH variable much easier. I include the
manpage and would like to know whether there is an interest in this program.

I haven't used it so far either, but I know that setting up a correct path
can be a hassle.

Michael
-- 
Dr. Michael Meskes      | Th.-Heuss-Str. 61, D-41812 Erkelenz | Go SF49ers!
Senior-Consultant       | business: Michael.Meskes@mummert.de | Go Rhein Fire!
Mummert+Partner         | private: Michael.Meskes@usa.net     | Use Debian
Unternehmensberatung AG |          Michael.Meskes@gmx.net     | GNU/Linux!
.TH PATH 1 \" -*- nroff -*-
.SH NAME
path \- manipulate PATH environment variable
.SH SYNOPSIS
.B path [option path ...] ...
.SH DESCRIPTION
The
.B path
program is used to manipulate the list of paths
contained in the PATH environment variable.
New paths can be added either to the beginning or the end of the path list,
and paths can be removed from the path list.
All duplicate paths in the list are removed.
.PP
The normal output of the
.B path
program is a colon-separated path list based on the PATH environment variable
and modified according to the arguments on the command line.
To install the new path list into the PATH environment variable,
you must use the shell's feature to capture and use program output.
Here is the method to set the modified PATH value:
.sp
.nf
PATH=`path [options]`
.fi
.sp
The back-quotes run the path program and capture its output,
and that output is then used to set the new value of PATH.
.PP
Most options specified for
.B path
specify an action which affects all of the paths which follow the option,
until the next such option which accepts paths as arguments.
Some options (-dd, -ci, -ri, -cr, -rr, and -l) do not use path arguments
and do not change the previously specified action.
As options and paths are acted upon, the path list is modified to make
a new path list.
When all of the command line arguments have been processed,
the final path list is usually printed as the output of the program.
.PP
The -a option adds the following paths after the last path in the path list,
if those paths are not already present in the list.
If a path is already in the path list, then it is not moved.
This option is the default option, so that if paths are specified for
.B path
with no preceeding options, then they will default to using this action.
.PP
The -b option adds the following paths before the first path in the path list,
if those paths are not already present in the list.
If a path is already in the path list, then it is not moved.
.PP
The -r option removes the following paths from the path list,
if those paths are present.
Nothing is done if a path is not in the path list.
.PP
The -ra and -rb options act like a combination -r and -a or -b option.
They first remove the paths if they exist in the path list,
and then add them back in to the beginning or end of the path list.
These are used to put paths at the beginning or end of the path list
without caring if they were already there.
.PP
The -ma and -mb options conditionally move the following paths to the
front or the end of the path list.
If the path is not in the path list, then it is NOT added.
If the path is in the path list,
then it is moved to the front or back of the path list as indicated.
This is useful, for example,
to reposition DOT to the front or end of the path list,
without adding it in if it wasn't already there.
.PP
The -s option simply sets the path list to the following list of paths.
This is the same as removing all of the paths in the path list,
and then adding in the specified paths to make a new path list.
.PP
The -ci option checks the absolute paths in the final path list for validity,
and reports to standard error those paths which are not valid.
Valid paths must exist and must be a directory.
Relative paths in the final path list are not checked.
If this option is used, then the final path list is NOT printed,
and the exit status will be 2 if any of the absolute paths are invalid.
.PP
The -ri option checks the absolute paths in the final path list for validity,
and silently removes the invalid absolute paths from the path list.
.PP
The -cr option checks the final path list to see if it contains any
relative paths (those not beginning with a slash),
and reports any relative paths in the path list to standard error.
If this option is used, then the final path list is NOT printed,
and the exit status will be 2 if any relative paths were found.
.PP
The -rr option checks the paths in the final path list for relative paths,
and silently removes all relative paths from the path list.
.PP
The -l option modifies the output format so that the paths in the path list
are displayed one path per line without any colons.
This is useful when you want to visually examine the list of paths,
or when you want to use the list of paths in a shell command.
The order of output is as determined by the path list,
but the output can be piped to the
.B sort
program if you want a sorted list.
.PP
Typing
.B path
with no arguments is useful just to clean up the PATH environment variable,
since it will remove all duplicated paths without doing anything else.
.SH SPECIAL DOT HANDLING
The DOT path ("." for the current directory) is normally treated
specially by the
.B path
program.
This special treatment exists because many people only want the DOT
path to be used at the front or the back of the path list,
and want to use the DOT path even if other relative paths are not used.
.PP
Firstly,
.B path
detects whether DOT was the first or last path in the original path list.
If so,
then after the path list has been modified by the command line arguments,
if the DOT path is in the middle of the final path list then it is moved
back to its original position in the list.
.PP
Secondly, the -cr and -rr options which check for and remove relative
paths in the the path list do not complain about or remove the DOT path.
.PP
If special treatment of the DOT path is not desired,
then using the -dd option disables the special treatment,
making DOT act just like any other path.
.SH EXIT STATUS
On normal execution the exit status is 0.
If a fatal error occured, the exit status is 1.
If the -ci or -cr options were used and found an invalid path,
the exit status is 2.
.SH BUGS
When adding paths to the beginning of the path list,
the paths are acted upon individually as they are seen on the command line.
This means that if you add multiple paths to the beginning of the path list,
then their order in the path list will be the reverse order that you specified.
So to get the right result, you must remember to add them in reverse order.
This is not a problem when adding multiple paths to the end of the path list.
.SH AUTHOR
.nf
David I. Bell
dbell@canb.auug.org.au
.fi

Reply to: