BASH: how to pass a default argument if no arguments after the first were passed
I'd try to use bash variable substitution:
test)
shift
docker exec -it $(docker-compose ps -q web) python manage.py test "${@-apps}"
;;
Other way is to check $*
instead of $1
:
case $* in
bash)
...
test)
docker exec -it $(docker-compose ps -q web) python manage.py test apps
;;
test\ *)
docker exec -it $(docker-compose ps -q web) python manage.py test "${@:2}"
;;
something like this would work well
if [ -z "$2" ]
then
echo "No argument supplied"
fi
case $1:$# in
(test:1)
docker $(this is bad) python test apps;;
(test:$#)
docker $(still bad) python "$@";;
(bash:$#)
docker ...
esac