I am working on a script that will check if an application is present and then run some commands. I am trying to write this so that I can easily change it later for a different application so I am putting the application and the path in a variable. The problem I have run into is that there are spaces in the path and so I am having trouble getting the IF statement to work and other commands. I think it is just where and when to put quotes and the character. If I take out the variable and place the path directly everything is fine.
Below is the main part I am trying to get working. If I can get that to work then I am sure I can get the rest of it.
#!/bin/bash Apple_Installer="/Applications/Install macOS Mojave.app" if [ -d "$Apple_Installer" ]; then Installer_Version=$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$Apple_Installer"/Contents/Info.plist) else echo "Not Present" fi exit 0