Given a (PATH-like) colon-separated string - this tool prepends a value to the string.
Importantly, prependpath is idempotent because it removes existing duplicates of the value in the string.
prependpath [value] [colon-separated-values]export PATH=$(prependpath "/my/path/bin" "$PATH")# Build using the default C compiler
cc prependpath.c -o prependpath -O2 -Wall -Wextra
# Install to /usr/local/bin
sudo cp prependpath /usr/local/bin/prependpathHow is this different from just doing the following?
export PATH="/my/path/bin:$PATH"If /my/path/bin already exists in PATH, it will be removed so that the entry is not duplicated. This makes it convenient for usage in ~/.zshrc or ~/.bashrc as it avoids ever-growing PATH-variables when nesting shells.