I am using a MacOS osascript
command in a shell script and I try to run the following command:
APPNAME=$@
if pgrep -x "$APPNAME" > /dev/null # checking if app is open
then
echo "Closing..."
osascript -e 'quit app $APPNAME'
else
echo "*** The app is not open"
fi
Ideally, the command would be osascript -e 'quit app "Calendar"'
as an example of a working solution. However, I can't seem to insert a variable in-between ' ' quotation marks.
What would be a workaround?