Skip to content

Zuzzuc/Bash-minifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bash-minifier

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.

Usage

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.

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 prompt the user at any time.

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


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 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" 


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 -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

About

Script used to minify bash scripts

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages