#!/usr/bin/env bash #myscript.sh if [[ "$1" == "" ]] then echo "Hello, " elif ! [[ "$1" =~ "*[a-z]*[A-z]" ]] then echo "Usage: error_handling.sh $1" elif [[ "$1" != "" ]] then echo "Hello, $1" else echo "Usage: error_handling.sh $1" fi The intention of the above script is to throw (custom) error when script is run like this:
./myscript.sh Alice i.e. it shows error as:
"Usage: error_handling.sh Alice" But if the same script is run like this:
./myscript.sh "Alice" it should show:
Hello, Alice But it throws the custom error statement for both the conditions.
How can this be resolved?
3 Reset to default