I was running a script and got the error: ./run.sh: line 21: $1: unbound variable
Here it is
# Make sure we have something to run
**if [ "$1" = "" ]; then
** log "Usage: $0 program [args]"
exit 1
fi
Any help would be greatly appreciated!
I didn’t write the code and I have no experience, so I don’t even know where to start.
ARCAN3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
Remove set -u
(short syntax) or set -o nounset
(long syntax) from your not shown code.
From help set
:
-u
: Treat unset variables as an error when substituting.
If you didn’t write the script and have no intentions of fixing it, assume it’s not handling the errors in a great way and, in this case, just provide the argument expected (which perhaps you know)
./run.sh whatever