Skip to main content

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

https://python.höllmanns.de/utok/

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyutok-1.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pyutok-1.1.2-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyutok-1.1.2.tar.gz.

File metadata

  • Download URL: pyutok-1.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.10.1-1-default

File hashes

Hashes for pyutok-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3036afe522451ca2f8ed9b42fe4956d8fd4c2e730bb3feb32ef5b4e5c716b6ce
MD5 3974b7a54546850b1e0cf987046f8501
BLAKE2b-256 05489f1a9108f1d44ad3db1d5d8764ba360f03f2c4f84e57f967b1347777e94d

See more details on using hashes here.

Provenance

File details

Details for the file pyutok-1.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pyutok-1.1.2-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.1.4 CPython/3.9.1 Linux/5.10.1-1-default

File hashes

Hashes for pyutok-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c4e2b6de84bf7375876ebeae9dba0769739580cf9d6a2a778256c66ea94de198
MD5 06697e12a285b9c48c864808bfa13be1
BLAKE2b-256 3b940e6aee93b9c58e033125326212f4259da00e4b30be7c264e8cb0c24e6f57

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page