unison-jz works well on a bash command-line but not inside a script. It seems that inside the script, it falls back to the regular unison command. Can someone tell me how to use unison-jz inside a bash script?
I had the unison version conflict that is described in #583058 and the proposed solution for ubuntu works fine on an interactive shell.
However, I want to do the same from inside a bash script:
#!/bin/bash
unison profile_name -sshargs '-i ~/.ssh/privatekey'
This is a MWE version of the script.sh (in reality the script is more copmlex, but I checked this MWE and it shows the same faulty behaviour). When I invoke this script from the same command line as before (but also from another shell), it seems that inside the script, the regular unison version is used instead of the snapped unison-jz (which is used when invoking from the interactive shell). Hence, the syncing fails with the same Fatal error as before, saying "This can happen because you have different versions of Unison installed on the client and server machines", which I had fixed with the above approached.
How can I make the shell script use the snapped unison-jz version instead of unison?
Both client and server use bash shell on ubuntu (client: 20.04, server: 18.04).
What I've done on the command-line:
Install snap:
sudo snap install --devmode unison-jzAdd this line to my unison profile file:
servercmd = /snap/bin/unison-jz.unison -ui textComment out line 19 in
/etc/ssh/ssh_configso that is looks like# Include /etc/ssh/ssh_config.d/*.confExecute unison:
unison profile_name -sshargs '-i ~/.ssh/privatekey'
This works fine from an interactive bash shell.