I'm trying to write a generic script to set default app for a document type e.g. PDF using https://github.com/Lord-Kamina/SwiftDefaultApps/releases
This works from a policy where $4 is set to: /Applications/Nitro\\ PDF\\ Pro.app
and $5 is set to com.adobe.pdf - but in the script I explicitly ignore $4 and set application_name
#!/bin/bash
# SetDefaultApplication.bash
#application_name="$4"
application_name=/Applications/Nitro\\ PDF\\ Pro.app
echo $application_name
# e.g. /Applications/Nitro\\ PDF\\ Pro.app
uti_name="$5"
# e.g. com.adobe.pdf
currentUser=$(stat -f%Su /dev/console)
# setHandler
sudo -u $currentUser /usr/local/libexec/swda setHandler --application "$application_name" --UTI $uti_name
and in the policy I see the output as:
Script result: /Applications/Nitro PDF Pro.app
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.gonitro.NitroPDFPro
But, if I try and use $4
#!/bin/bash
# SetDefaultApplication.bash
application_name="$4"
#application_name=/Applications/Nitro\\ PDF\\ Pro.app
echo $application_name
# e.g. /Applications/Nitro\\ PDF\\ Pro.app
uti_name="$5"
# e.g. com.adobe.pdf
currentUser=$(stat -f%Su /dev/console)
# setHandler
sudo -u $currentUser /usr/local/libexec/swda setHandler --application "$application_name" --UTI $uti_name
I get an error from the policy
Script result: /Applications/Nitro\\ PDF\\ Pro.app
SwiftDefaultApps ERROR -10814: No application found for /Applications/Nitro\\ PDF\\ Pro.app
and yet on that machine, I can run the script as root
dep54592:lab root# ./SetDefaultApplication.bash 1 2 3 /Applications/Nitro\\ PDF\\ Pro.app com.adobe.pdf
/Applications/Nitro PDF Pro.app
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.gonitro.NitroPDFPro
Just wondering if anyone can see where I'm going wrong?