Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

WorkingDirectory not supported if it CONTAINS $APP_PACKAGE as part of a path #12

Closed
Dylan-M opened this issue Feb 14, 2015 · 5 comments
Closed
Labels

Comments

@Dylan-M
Copy link

Dylan-M commented Feb 14, 2015

This is our WorkingDirectory key/val pair from our plist
WorkingDirectory
$APP_PACKAGE/../

The $APP_PACKAGE never gets correctly replaced with ${AppPackageFolder}

I would assume the same is true for all of the entries that check for equality instead of contains, and should probably do a contains check with a replace instead of an equality and a set.

I hope that's clear, I'm rambling a bit today. Mostly because I can't get my thoughts into any type of clear and concise order.

I assume some trick with sed would work, but I'm not very good with sed, so my hackish attempt is thus
elif [[ "${JVMWorkDir}" =~ "$APP_PACKAGE" ]]; then
WorkingDirectory="${AppPackageFolder}"$(sed 's|$APP_PACKAGE||g' <<< ${JVMWorkDir})

And... seems to work. At least, I can enter the app and manually run the script and it works. Or I can do open App.app from the command line and it works. However, trying to double click the app to have it work from the GUI still fails.

@karog
Copy link

karog commented Feb 20, 2015

I just ran into the same problem. I fixed it thus:

Change

elif [ "${JVMWorkDir}" == "$APP_PACKAGE" ]; then
WorkingDirectory="${AppPackageFolder}"

To

elif [ "${JVMWorkDir:0:12}" == "$APP_PACKAGE" ]; then
WorkingDirectory="${AppPackageFolder}${JVMWorkDir:12}"

Where 12 is the length of $APP_PACKAGE

and do similar for the other cases where lengths will differ.

@Dylan-M
Copy link
Author

Dylan-M commented Feb 21, 2015

That's an even more elegant solution than mine, I had forgotten about bash substring capabilities

@tofi86
Copy link
Owner

tofi86 commented Feb 22, 2015

Hi @Dylan-M, @karog,

thanks for reporting this and for providing a bugfix solution.
Will be fixed in the next maintenance release! :)

@tofi86
Copy link
Owner

tofi86 commented Feb 22, 2015

While the bash substring solution still is a very nice idea to solve this issue, I'll stick to the same solution as for the ${JVMClassPath} variable where all occurances of inline variables get expanded by the following eval:

# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
JVMClassPath=`eval "echo ${JVMClassPath}"`

@Dylan-M
Copy link
Author

Dylan-M commented Feb 22, 2015

That works too, I hadn't even considered it since I'm really a Linux guy and I'm never quite sure exactly what will work on a Mac without doing extensive testing :D I didn't have time to do extensive testing when I hacked the script. I needed it to work "now", as they say.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants