4

I understand that you can change a LaunchAgent's working directory with a WorkingDirectory key, but is there any way to set the Working Directory to a user's home directory reliably and portably within the plist? Can I do something like:

<key>WorkingDirectory</key>
    <string>~</string>

and have it work?

  • 1
    Is there some reason that you could not just test this to get the answer? – user3439894 Jul 19 '15 at 18:15
  • ~ and $HOME don't seem to work. – Roger Filmyer Jul 19 '15 at 22:46
  • Shell expansion only works if you EnableGlobbing and only in the keys Program and ProgramArguments – fd0 Jul 19 '15 at 23:41
  • 2
    @Roger Filmyer- You are still missing my point. launchd isn't a shell. ~ tilde expansion and $HOME variable expansion are done by a shell. So, to answer your question, you cannot use either in the key WorkingDirectory nor is there a reliable way to do this within a portable launchd.plist. My suggestion would be to change directories within a shell script. Of course I have no idea what you are trying to achieve. – fd0 Jul 20 '15 at 16:51
  • 1
    @martin-martin- Feel free to provide an answer to the question. I'll up vote your answer and remove my comments. – fd0 Jun 27 '18 at 13:02

You must log in to answer this question.

Browse other questions tagged .