Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from iande/gist:959065
Created May 6, 2011 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayneeseguin/959068 to your computer and use it in GitHub Desktop.
Save wayneeseguin/959068 to your computer and use it in GitHub Desktop.
First Stab @ package_error
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}
}
@iande
Copy link

iande commented May 6, 2011

When $(tail) is assigned to a variable, the new lines seem to be lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment