diff --git a/share/fsl/sbin/createFSLWrapper b/share/fsl/sbin/createFSLWrapper index 105efc8c4fd3955f6538f6276a57623575da9719..cfb9c6e11cce882458dbb0d7963a559a659422f1 100755 --- a/share/fsl/sbin/createFSLWrapper +++ b/share/fsl/sbin/createFSLWrapper @@ -85,27 +85,29 @@ for script in $targets; do # Figure out whether this is a python # executable or some other type of - # executable. We search for these strings - # in source file headers to ID them as - # python scripts. We need to check both - # match "#!/usr/bin/env python" and - # "#!<fsldir>/bin/python...", because - # conda might generate one or the other - # in different scenarios. - id1=$(head -c 1024 "$sourceScript" | grep "#!/usr/bin/env python") - id2=$(head -c 1024 "$sourceScript" | grep "#!${FSLDIR%/}/bin/python") + # executable. + id=$(head -c 1024 "$sourceScript" | grep -e '^#!.*pythonw\?$') - # Non-python executable - use a - # pass-through script - if [ -z "$id1" ] && [ -z "$id2" ]; then + # Non-python executable - use + # a pass-through script + if [ -z "$id" ]; then echo "#!/usr/bin/env bash" > "$targetScript" echo "$FSLDIR/bin/$script "'"$@"' >> "$targetScript" else # Python executable - run it via - # $FSLDIR/bin/python in isolated mode - echo "#!/usr/bin/env bash" > "$targetScript" - echo "$FSLDIR/bin/python -I $sourceScript "'"$@"' >> "$targetScript" + # $FSLDIR/bin/python[w] in isolated + # mode. Under macOS, GUI apps are + # invoked with pythonw, so we need + # to preserve the interpreter. + if [[ "$id" == *"pythonw" ]]; then + interp="pythonw" + else + interp="python" + fi + + echo "#!/usr/bin/env bash" > "$targetScript" + echo "${FSLDIR}/bin/${interp} -I $sourceScript "'"$@"' >> "$targetScript" fi # Preserve file permissions