I am trying to run the scripts as below. I want to set the flags to true but it doesnt work.
./test.sh ./api_service -s -i
if I run the scripts only with flags i am able to get the expected output. how to pass arguments and flags to the script?
./test.sh -s -i
script:
#!/bin/bash
input_project_path="$1"
name=$(echo ${input_project_path} | cut -d"/" -f2)
echo $name
skiptests=false
install_libs=false
while getopts ":si" option; do
case "${option}" in
s )
skiptests=true
if [ "$skiptests" = true ] ; then
echo "something....";
else
echo "test...";
fi
;;
i)
install_libs=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo $skiptests
echo $install_libs