diff options
| author | St33v <github@f3rr3t.com> | 2021-10-17 15:19:27 +1100 |
|---|---|---|
| committer | St33v <github@f3rr3t.com> | 2021-10-17 15:19:27 +1100 |
| commit | ad4be3dd58ab5d86fb9c55c0633c94ef6d85030a (patch) | |
| tree | b234fced94795e30872e899e41263d194d81106c /resize.sh | |
| parent | 1712147f3504f54786f0c4d700251936d5e51621 (diff) | |
Add some error checking for reduction percentage
Diffstat (limited to 'resize.sh')
| -rwxr-xr-x | resize.sh | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -6,6 +6,18 @@ if [ -z $1 ] then reduce=25 else reduce=$1 + re='^[0-9]+$' # reg expression for digits only + if ! [[ $reduce =~ $re ]] + then + echo "Usage: If you use arguments, arg 1 (resize percentage) must be an integer" + exit 1 + else + # arg1 is an integer + if [ $reduce -gt 99 ] || [ $reduce -lt 1 ] ; then + echo "Usage: reduction percentage must be between 1 and 99 percent" + exit 1 + fi + fi fi # Check for folder name in command line (no spaces of course!) |
