Say I've got this:
#!/bin/sh
function show_help {
cat<<%
Usage: $0 [-h]
%
}
# the following lines is pseudo-code
if argument contains "-h"
show_help
otherwise
do_stuff
If I run ./test it does some stuff as intended, but if I run ./test -h, it produces
Usage: show_help [-h]
but I intended to let it produce
Usage: ./test [-h]
so how can I achieve this by modifying only the show_help function? I don't want to modify the script itself, so I won't just add SCRIPT_NAME=$0 under the shebang line.
I hope the solution is some kind of a builtin variable like $PWD or function like pwd, does there really exist one?
show_help.kshcause the problem when/bin/shis linked todashand the question is tagged bash?