Last Updated: 2021-05-16
Whenever printing error messages from shell scripts, make sure to redirect to STDERR, otherwise callers will not be able to react correctly.
Here is what you should do
echo "$lesson not found. Please contact customer support" >&2
Here's how it works:
&2 copies the destination of file descriptor #2 (STDERR
by default). The
echo where to send the output that is usually
STDOUT (file descriptor #1). Bringing it together, this means echo's standard
output gets sent to STDERR.