Inspired by a tool I can not find anymore on the internet: utok 1.5. I use it to clean up path settings in large shell script configuration setups.
Project description
Inspired by a tool I can not find anymore on the internet: utok 1.5. I use it to clean up path settings in large shell script configuration setups.
utok has the following options:
usage: utok [-h] [--delimiter DELIMITER] [--delete-list DELETE_LIST] [--version] tokens [tokens ...] positional arguments: tokens optional arguments: -h, --help show this help message and exit --delimiter DELIMITER, -s DELIMITER Allows one to change the delimiter. If you use csh you might want to set your path with something like: set path = (`utok -s \ /usr/local/bin $path`) (default: :) --delete-list DELETE_LIST, -d DELETE_LIST Allows one to remove tokens from a list, to remove /usr/sbin and . from a path in Bourne Shell one might use: PATH=`utok $PATH -d .:/usr/sbin` (default: None) --version, -V show program's version number and exit
Homepage
Availability
The latest version should be available at my GitLab repository, the package is avaliable at pypi via pip install pyutok.
Description
utok, Unique TOKens, takes a list of arguments with delimiters and reject all duplicate entries. Here is a example using MANPATH:
$ echo $MANPATH
/usr/man:/usr/local/man
$ MANPATH=`utok /home/local/man /usr/local/man $MANPATH /usr/openwin/man`
$ export MANPATH
$ echo $MANPATH
/home/local/man:/usr/local/man:/usr/man:/usr/openwin/man
Even though /usr/local/man was included a second time it is only in the MANPATH once, though it is now before the /usr/man entry instead of after it.
This version adds the -d option to remove tokens. To remove . from the PATH one would do the following:
$ echo $PATH
/usr/local/bin:.:/usr/bin:/usr/sbin
$ PATH=`utok -d .: $PATH`
$ echo PATH
/usr/local/bin:/usr/bin:/usr/sbin
$ export PATH
Requested Features
Have a way to to push an element further back in the path. A work around of this would be be something like:
utok `utok a:b:c:d -d b` b
which returns: a:c:d:b
Have a way to include multiple -s options.
Feedback
Comments or bug reports/fixes go to Berthold Höllmann <berhoel@gmail.com>.
Copyright © 2020 Berthold Höllmann <berhoel@gmail.com>
Original C version: Copyright © 1998 Sven Heinicke <sven@zen.org>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyutok-1.1.0.tar.gz
.
File metadata
- Download URL: pyutok-1.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.3 Linux/5.6.14-1-default
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 025db0d40935618d9c4a3159878e109490bc99bbd4a0ab52c6e99aeb1d291f49 |
|
MD5 | 0596e4bbdde0c03dd610dbbb34318b88 |
|
BLAKE2b-256 | a971fc0f21d5f90e57bbbf8a90be86b2ae0c24e3816cdf18b4bc3b96f042117d |
Provenance
File details
Details for the file pyutok-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pyutok-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.3 Linux/5.6.14-1-default
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38b7f18bec4c1448a2cbdd2773e860001776b7f69d60db1c8da6adf1a1242199 |
|
MD5 | 843c6bbbd1ea1521067fd67d815d703f |
|
BLAKE2b-256 | c4db0e49e18dcc233a1c1f617280cfad568aab46a743de362c4a8009f76b2e01 |