diff --git a/nyan b/nyan index e344b70..58b1bfb 100755 --- a/nyan +++ b/nyan @@ -10,19 +10,19 @@ if [ ! -e "$(which pv)" ]; then fi function simplify_size_number { - declare -i bytes=$1 - declare -i kilobytes=$((bytes/1024)) + local declare -i bytes=$1 + local declare -i kilobytes=$((bytes/1024)) - size_str="" + local size_str="" if [ $kilobytes -lt 1024 ]; then size_str="${kilobytes}kb" else - declare -i megabytes=$((kilobytes/1024)) + local declare -i megabytes=$((kilobytes/1024)) if [ $megabytes -lt 1024 ]; then size_str="${megabytes}mb" else - declare -i gigabytes=$((megabytes/1024)) + local declare -i gigabytes=$((megabytes/1024)) size_str="${gigabytes}gb" fi fi @@ -33,10 +33,15 @@ while getopts ${optstring} args; do case $args in o) output_file=${OPTARG} ;; :) echo "Output file required." ;; + # TODO: Expand this into something nicer looking. h) echo "Usage: nyan -o [OUTPUT FILE] [INPUT FILE]..." && exit 0 ;; esac done shift $((OPTIND-1)) +if [ -z "$output_file" ]; then + echo "Error: no output file specified." + exit 1 +fi echo "Concatenating files..." declare -i total_size=0 @@ -54,6 +59,8 @@ for fname in "$@"; do fi done +# TODO: Make sure that output_file does not exist. Maybe add an overwrite switch. + if [ $abort -eq 0 ]; then cat "$@" | pv -epts "$total_size" > "$output_file" echo "Done!"