Another standard library for shell (bash/zsh) with cross-shell support
The std.sh
provides various sourceable cross-shell scripts that can be used by downstream as dependencies to detect OS type or Package Manager installations.
As of v1.0.0
only provides system-related functions and variables ONLY.
NOTE: Do not use some of these scripts in CMake-based projects; use built-in variables instead.
Examples of scripts:
- std-sys-os.sh
A cross-platform system-detection script - provides variables like
OS_LINUX
,OS_LINUX_DEBIAN
orOS_BSD
etc.; use cases include usage for specific system installation via shell scripts - std-sys-package-manager.sh
A cross-platform package-manager detection script - provides variables likePM_PKG
,PM_DPKG
,PM_YUM
etc. ; use cases - detection of package manager for C/C++ project dependency installation - More at doc/std-sh.md
By using basher:
basher install --ssh hinell/std.sh
Use it like so in your script:
inclue hinell/std.sh src/std-sys-os.sh
git clone --depth 1 git@github.com:hinell/std.sh.git /tmp/sh.std
cd ${_}
./config install --user # install to ~/.local/bin
./config link --user # link to ~/.local/bin - dev-only
sudo ./config install # install into /usr/bin
The above will put executable/sourceable scripts into ${HOME}/.local/bin/
folder.
Don't forget to set PATH
in your ~/.bashrc
/.zshrc
if you want to use user-local installation of executable scripts:
if [[ -d "$HOME/.local/bin" ]];
then
PATH="$HOME/.local/bin:$PATH"
fi
Depending on the installation method, use:
basher uninstall hinell/std.sh
# or
rm $HOME/.local/bin/std-*
# or
For full details see doc/std-sh.md. E.g.:
source $(which std-sys-os.sh) || { exit 1; }
source $(which std-sys-package-manager.sh) || { exit 1; }
# etc
NO GUARANTEES UNTIL PAID. This project is supported and provided AS IS. See also LICENSE.
December 18, 2023
Copyright © 2023 - Alexander Davronov (a.k.a. github@hinell), et.al.