#!/bin/bash function send() { command="$1" shift echo " $@" } function send_error() { if [ "$#" -gt 1 ]; then send error "$@" elif [ "$#" -eq 1 ]; then send error "$1" "$(tr -d '\n')" else send error 255 unknown fi return 1 } function emit_progress() { percent=$1 [ "$percent" -gt 100 ] && percent=100 send progress "$percent" }