Ask Different Asked on December 3, 2021
How can I make SnailSvn use vimdiff or any custom diff script? It only has a predefined list of options.
To setup its diff support (for opendiff aka FileMerge), it asks you to copy the following script to:
~/Library/Application Scripts/net.langui.SnailSVN.DiffTool/difftool.sh
#!/bin/bash
pkill -nf ScriptMonitor
sh "$@"
The argument is a generated diff-cmd.sh file that looks something like this:
#/bin/bash
"/Applications/Xcode.app/Contents/Developer/usr/bin/opendiff" "/var/folders/nn/000000000000000000000000000000/T/net.langui.SnailSVNFree//r422640 Code.cs" "/Users/idbrii/code/game/Assets/Standard Assets/Unlit/Planes/Code.cs"
I tried to replace it with something like:
#!/bin/bash
args=$(grep opendiff "$@" | cut -d -f2-)
echo mvimdiff $args >> ~/snailsvndifftool.log 2>&1
But instead I get too many files — despite files containing quotes, they’re still split up by spaces.
With the help of this answer, I found eval
:
#!/bin/bash
args=$(grep opendiff "$@" | sed -e 's,"/Applications/Xcode.app/Contents/Developer/usr/bin/opendiff",/usr/local/bin/mvimdiff,')
echo diff: $args >> ~/snailsvndifftool.log 2>&1
# What's this shady thing?
eval $args >> ~/snailsvndifftool.log 2>&1
However, doing eval
on arbitrary arguments seems unnecessarily insecure and I couldn't get arrays to work (i.e., mvimdiff ${args[@]}
), so instead I force mvimdiff to be at the beginning of the line and only allow a set of characters:
#!/bin/bash
args=$(grep opendiff "$@" | sed -E 's,"/Applications/Xcode.app/Contents/Developer/usr/bin/opendiff",,; s/[^A-Za-z0-9.~/"_ -]//g; s,^,/usr/local/bin/mvimdiff,')
echo diff: $args >> ~/snailsvndifftool.log 2>&1
eval $args >> ~/snailsvndifftool.log 2>&1
There's probably something I'm missing, so I hope someone has a better answer.
Answered by idbrii on December 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP