I've been trying to repackage an installerI was trying to cut down on some code on a post install script by utilizing functions. When I try to run the installer command and target $3, it's not actually targeting /. Rather it is an empty value which means the installer never launches. However, if I run the same installer command outside of a function, it targets $3 and correctly installs to /.
If I run the script with bash set x, I can see the following line in console when using the installer command targeting $3 in a function:
1/usr/sbin/installer -dumplog -verbose -pkg '/Volumes/path/to/installer.pkg' -target '' -allowUntrusted
Outside of a function, installer command targeting $3 results in:
1/usr/sbin/installer -dumplog -verbose -pkg '/Volumes/path/to/installer.pkg' -target / -allowUntrusted
If I use the installer command and target / instead of $3, the command will also work within a function, but I know that's not the proper way to do things.
It's been a long day and this is probably an easy one. I'm guessing it has to do with certain variables not being passed to a bash function. What am I missing here?
Relevant portion of the script:
1#!/bin/bash23#Working directory for script to reference resources4install_dir=`dirname $0`56# Determine OS version7osvers=$(sw_vers -productVersion | awk -F. '{print $2}')89#Variables for ScanSnap installer10ScanSnapDMG="ScanSnap.dmg"11ScanSnapDMGVolume="/Volumes/ScanSnap"12ScanSnapInstaller="ScanSnap Manager.pkg"1314ScanSnap () {15 /usr/bin/hdiutil attach -nobrowse -readonly $install_dir/"$ScanSnapDMG"16 /usr/sbin/installer -dumplog -verbose -pkg "$ScanSnapDMGVolume/$ScanSnapInstaller" -target $3 -allowUntrusted17 /bin/sleep 1018 /usr/bin/hdiutil detach "$ScanSnapDMGVolume"19 /usr/bin/killall "ScanSnap Manager"20}2122if [[ ${osvers} -le 7 ]]; then23 ScanSnap24fi2526exit 0
EDIT: For clarification, I'm not testing in the JSS yet. I'm only testing in 10.9.5 and creating the package in Packages.