A bash script used to minify other bash scripts.
This script will attempt convert any bash script to a one liner (or two lines if counting the shebang) using a state aware parser. This is not always possible for a valid bash syntax, for example with heredocs, which will be left in place.
Example usage:
/Minify.sh -f="$HOME/Desktop/test.sh"
This will minify a script named "test.sh" on the desktop and output its content to stdout.
/Minify.sh -f="$HOME/Desktop/test.sh" -o="$HOME/Desktop/output.sh"
This will do the same, but will write the output to a file named "output.sh", and give it execution permissions(due to default settings not overrun), on the users desktop.
/Minify.sh -F -f="$HOME/Desktop/test.sh" -o="$HOME/Desktop/output.sh" -p=u-r
This will minify and write the script to desktop, and remove read access for the current user from it.
This option chooses what file to read from.
Example: ./Minify.sh -f=test.sh
If this option is enabled the script will skip any security checks and will therefore not prompt the user at any time.
Example: ./Minify.sh -F -f=test.sh
This option specifies where to send the output.
STDOUT will simply send the output to stdout.
File will write the output to a file. To activate this option, simply specify a file path. If a file already exists in the filepath, the script will prompt the user and ask if the file should be overwritten.
Examples: ./Minify.sh -F -f=test.sh -o=STDOUT./Minify.sh -F -f=test.sh -o="$HOME/Desktop/output.sh"
This option will, in case of the output being a file, set the file permission to the content of the parameter
Example: ./Minify.sh -F -f=test.sh -o=$HOME/Desktop/output.sh -p=u-r
0: Everything went well
1: Unknown error
2: User declined to continue when warned
3: File does not exist
4: Unknown argument supplied to script
5: This script will not minify itself
6: Unknown output mode encountered