Chemability is a POSIX script that scans other POSIX and non-POSIX scripts containing commented identifiers with required and optional commands/builtins. Note that builtins checks will only work on Bash builtins.
overview.mp4
Usage:
chemability [options] [arg]
Options:
-h Displays this help message
-r Whether to scan directories recursively
-s Whether to skip optional
-f Whether to fail when optional is unavailable
-i <pattern> Ignore scanning a file/directory that matches the patternBy default if Chemability ran without arguments it will scan scripts in the current directory, Chemability can take files and directories as arguments and options -r for recursive scanning and -i for ignore pattern.
Pattern recognition is limited, only simple patterns like '*.bak' will work, make sure to quote it.
Colors can be enabled by using environment variables:
- Set
CLICOLORto1to enable auto-detecting color support. - Set
CLICOLOR_FORCEto1to always force color output.
Root check can be skipped by Setting CHEMABILITY_NO_ROOT_CHECK to 1 to skip root check.
#!/usr/bin/env bash
# There are five line identifiers you can use, each one is for a purpose.
# The syntax starts with '#CHEMA_' followed with a keyword without spaces.
# #CHEMA_REQ ...
# #CHEMA_REQ_BLT ...
# #CHEMA_OPT ...
# #CHEMA_OPT_BLT ...
# #CHEMA_CMD ...
# #CHEMA_END
# #CHEMA_END is not required, but it will tell the script to stop scanning the script and move on to the next file.
# it's recommended to have to make Chemability perform better for scanning a directory with a bunch of scripts.
# #CHEMA_REQ contains required commands needed for the script to work, #CHEMA_REQ_BLT is the same thing, but for Bash builtins.
# #CHEMA_OPT contains optional commands needed for some functionality to work, #CHEMA_OPT_BLT is the same thing, but for Bash builtins.
# #CHEMA_CMD is special, it's used primarly to run commands like apt, dnf, or pacman
# The syntax is the same for the last four, commands/builtins separated by ',' Chemability will trim spaces and tabs.
# you can add a comment to a command/builtin by adding ';' after the command/builtin then the comment, Chemability will also trim spaces and tabs for comments.Below is an example of a script with Chemability identifiers.
#!/usr/bin/env bash
#CHEMA_REQ sed; Used for parsing config file
#CHEMA_REQ_BLT getopts; Needed to parse command line arguments
#CHEMA_OPT uwsm; Used to launch with UWSM app
#CHEMA_OPT_BLT chmod; Used instead of system chmod for performance, rm; Used instead of system rm for performance
#CHEMA_CMD_sudo_pacman_-S_--needed_--noconfirm sed
#CHEMA_END
...
The output of Chemability would be like this
