Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Original (With a Few Comments):
- ####
- #!/bin/bash
- if [ "$1" == "-h" ]; then
- echo "Script for https://github.com/daniel-seiler/ImageTheming"
- echo "This script requires the .jar to be in the same folder as it" # Useless use of echo
- echo " -Script by Xyliad"
- exit 0
- fi
- FILE=ImageTheming.jar
- # Uppercase variable names are usually associated with global (environment) variables, while the variable declared here is a local one, see https://www.youtube.com/watch?v=9ZpL8iDU7LY
- # for the difference between those and for more info on shell variables
- if [ -f "$FILE" ]; then
- echo "Image Themer Script"
- echo "Please enter absolute image path"
- read imagepath
- echo "Please enter theme name/absolute path"
- read theme
- echo "Please enter output absolute path"
- read output
- java -jar ImageTheming.jar $imagepath -t=$theme -o=$output # Quoting the variables is probably a good idea
- echo "---Done---"
- else
- echo "$FILE not found"
- fi
- exit # There's no need to explicitly exit at the end of the script
- ####
- ### My version:
- ####
- #!/bin/bash
- if [ "$1" == "-h" ]; then
- echo "Script for https://github.com/daniel-seiler/ImageTheming
- This script requires the .jar to be in the same folder as it
- -Script by Xyliad"
- # You can also use echo -e 'Script for https://github.com/daniel-seiler/ImageTheming\nThis script requires the .jar to be in the same folder as it\n -Script by Xyliad'
- exit 0
- fi
- file=ImageTheming.jar
- if [ -f "$file" ]; then
- echo "Image Themer Script
- Please enter absolute image path "
- read imagepath
- echo "Please enter theme name/absolute path "
- read theme
- echo "Please enter output absolute path "
- read output
- java -jar ImageTheming.jar "$imagepath" -t="$theme" -o="$output"
- echo "---Done--- "
- else
- echo "$file not found" > /dev/stderr # echo as an error
- exit 1 # exit with non 0 exit code
- fi
- ####
- ### An Overcomplicated Way to Always Print the Credit Message on the Right Side
- ####
- #!/bin/bash
- spaces=$(( $(tput cols) - 18 )) #number of columns in the terminal right now, minus 18
- [ $spaces -lt 1 ] && spaces=1 #shorthand way of writing if [ $spaces -lt 1 ]; then spaces = 1; fi
- for i in {1..$spaces}; do # shorthand way of writing for i in `range ...
- echo -n ' '
- done
- echo '-Script by Xyliad'
- ####
Advertisement
Add Comment
Please, Sign In to add comment