Skip to content

Zuzzuc/Bash-minifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 

Repository files navigation

Bash-minifier

A script used to minify other scripts.

Does currently only support full line comments. This means that this will work

#!/bin/bash
# The next line will output the current date
date

whilst this won't work

#!/bin/bash
date # This will output the current date

Usage

This script will convert any script to a one liner(or two lines if counting the shebang). Following are some examples on how to use it

/Minify.sh -f="$HOME/Desktop/test.sh" This will minify a script named "test.sh" on the desktop and output its conent 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.

Supported options

File

-f or --file

Requires a parameter

This option is REQUIRED for this script to work.


This option chooses what file to read from.

Example: /Minify.sh -f=test.sh


Force

-F or -force

Should not be supplied with a parameter.

Disabled by default


If this option is enabled the script will skip any security checks and will therefore not promt the user at any time.

Example: /Minify.sh -F -f=test.sh


Mode

-m or --mode

Requires a parameter

Defaults to RAM


This option will specify what mode to use. Right now there is only one mode avaliable, RAM, but there will be multiple added in the future

RAM mode will read the whole script into RAM before making changes, and writing them to stdout or file first when all changes are complete.

Example: /Minify.sh -F -f=test.sh -m=RAM


Output

-o or --output

Requires a parameter

Defaults to STDOUT


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 promt the user and ask if the file should be overwritten.

Examples: /Minify.sh -F -f=test.sh -m=RAM -o=STDOUT
/Minify.sh -F -f=test.sh -m=RAM -o="$HOME/Desktop/output.sh" 


Permission

-p or --permission

Requires a parameter

Defaults to u+x


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 -m=RAM -o=$HOME/Desktop/output.sh -p=u-r

Exit codes

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

Releases

No releases published

Packages

No packages published

Languages