Shell variables in standalone app of bash script

bashterminal

I have a bash script that mounts a fuse filesystem created with the backup tool borg. Mounting the filesystem requires a passphrase. The mount command of borg allows to read the passphrase from an export in my shell script. So the first two lines of my script are something like

#!/bin/bash
export BORG_PASSPHRASE='mypassphrase'

Then I mount the filesystem with the mount command

borg mount user@server:/mntpoint::backup_repository /localmntpoint

The script runs perfectly fine. However, I would like to create a standalone app which runs this script. So I called the script Borg and created a directory Borg.app which contains Contents and MacOS as subdirectories and in MacOS I put the Borg shell script. This appears to be the usual way of turning a shell script into a clickable application. I am aware that one can click the shell script itself and a terminal will fire up and execute the script. I prefer the other option.

Unfortunately nothing happens upon clicking my Borg.app. I suspect the issue is the export command at the beginning which is somehow missed by the mount command in this setup.

Any help in resolving this is greatly appreciated.

Best Answer

Make sure that

  • the shell script within Borg.app is executable (chmod +x ...)
  • all the files within Borg.app are accessible by the current user
  • any command called from the script is called with the full path specified (especially for things stored in /usr/local/bin and similar non-default places)