-
-
Save wayneeseguin/959068 to your computer and use it in GitHub Desktop.
First Stab @ package_error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package_error() | |
{ | |
local _message=$1 | |
if [[ -z "${_message}" ]] | |
then | |
fail "Cannot print a package error as no message was provided." | |
fi | |
local _log=$2 | |
if [[ -n ${_log} ]] && file_exists ${_log} | |
then # Append tail of error log to the error message. | |
local _num_lines=${3:-25} # Default the number of lines to 25 | |
_message="${message}\n\n\tTail of %s\n\n" "${_log}:\n$(tail -n ${_num_lines} ${_log} )" | |
fi | |
error ${_message} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When $(tail) is assigned to a variable, the new lines seem to be lost.