Shorten "ERROR line $LINENO: ..."
Hi. Does anyone know a way to shorten the error message prefix with the $LINENO variable in shell scripts?
I would like to have Code:
$fatal "FILE not specified" Code:
echo "ERROR line $LINENO: FILE not specified" >&2 Code:
_fatal() { |
If you are using bash, BASH_LINENO gives you an array of all the line numbers in the call stack:
Code:
fatal() { |
I'm not following the request here. Why do you need to use eval? Why doesn't $LINENO expand on its own?
Is it because you're trying to call the function this way? Code:
fatal='eval _fatal $LINENO' Code:
fatal=$( _fatal "$LINENO" ) How about giving us some more context, and the actual contents of the function, so we can more easily know what you're trying to do? (As an additional point, having both a variable and a function with almost the same name is rather confusing. ) |
Quote:
|
All times are GMT -5. The time now is 05:31 PM. |