|
You can test, if the script was called with an argument:
[[ -z "$@" ]] && printf "No input\n" || printf "Input: %q\n" "$@"
Which means: if the length of the arguments ( $@) is zero (-z) then print "No input" else print the string in escaped form. I don't not, what you want to achieve, but if you try to escape strings, check the %q option of printf.
If you call the testscript this way:
testscript "h's m"
it will give you:
Input: h\'s\ m
|