Problem with Shell Script vs. Terminal (Git, Beyond Compare)

When I open a Terminal window in the appropriate folder and issue this command:

git difftool -y KMEditor.scpt

It opens Beyond Compare just like it should. (I have Beyond Compare set up as git's diff tool).

But if I do the same thing in a Shell Script from KM:

cd "/Users/Dan/Documents/Development/JXA/JXA Libraries/Dev/Sources"
git difftool -y KMEditor.scpt

I get this error:

The diff tool bc3 is not available as 'bcompare'
fatal: external diff died, stopping at Dev/Sources/KMEditor.scpt

The problem has nothing to do with the folder, or anything like that. It has something to do with how git resolves "bc3" - see the following.

When I set up Beyond Compare as git's diff tool, I followed the instructions at Scooter Software - Home of Beyond Compare. Specifically:

So somehow git resolves "bc3" to the application "bcomp", and this works from a terminal window. But it doesn't work from a shell script.

I've managed to cobble together a workaround involving a macro that opens a Terminal window and types in the necessary commands, but it's pretty kludgy.

Any help would be appreciated.

Hey Dan,

We've talked about the fact that Keyboard Maestro's Execute a Shell Script action creates an unadulterated environment.

You clearly have made changes to your log-in shell environment that aren't reflected in Keyboard Maestro's shell environment.

Scope these out:

-Chris

Thanks, Chris. I tried doing this:

#!/usr/bin/env bash
source ~/.profile;
cd "$KMVAR_zzFolderName"
git difftool -y "$KMVAR_zzFileName"

and it says:

/Users/Dan/.profile: No such file or directory

I don't have a clue where to go from there.

Hey Dan,

See if this works. It’ll run as a log-in shell.

#!/usr/bin/env bash -l
cd <hard-coded-path>;
git difftool -y <hard-coded-path>;

I haven’t gotten around to using git yet, so I don’t know how it manages its config files.

Have a look at this:

You may or may not have a ~/.bashrc file.

Type set in the Terminal and see what you find.

Look at all the invisible files in your home directory:

cd ~/;
ls -ld .*

Look for git specifically:

cd ~/;
ls -a | egrep -i "git"

When I do this sort of thing I normally fire up ForkLift or Path Finder and turn on show-invisibles, but the Terminal runs 24/7 on my system and is sometimes more convenient.

You can use the Finder to view invisibles, although I find this method inconvenient and don’t use it (since I have better tools for the job).

In the Terminal:

defaults write com.apple.finder AppleShowAllFiles -bool true; killAll Finder
defaults write com.apple.finder AppleShowAllFiles -bool false; killAll Finder

-Chris

Which reminded me to post these:

In Finder (I am on Sierra) I can toggle invisible files by using this shortcut Command-Shift-Period

3 Likes

Heck, this must be new with Sierra!? Previously it only worked in Open/Save dialogs.

Many thanks for the tip, this has totally escaped me!

Hey Jimmy,

I hope you are not malade,

your tip is really, exceptionally, really (yes, 2 times) great. Formerly I used Forklift or Terminal when I wanted to see the contents of my HOME folder or similar…

2 Likes

Hey Jimmy,

I'm with Tom – this is a great tip!

One small caveat – when using this method the Finder will NOT show you .DS_Store files.

Potentially that means other file types might be hidden at any time Apple sees fit, so I won't give up my forensic tools just yet.

That said – I don't anticipate needing them anymore for mundane stuff – I'm delighted to say.

Someone at Apple woke up and smelled the green tea...

-Chris

1 Like

Chris,

Hey, finally they – Apple got something right.

That Cmd-Shift-Period existed since 2003 or whatnot? In Save dialogs, of course. Only in dialogs. Of course. And , in case I forgot mention it , only in Save dialogs.

Wow, now, finally after 15 years OS X we can do this also in the damn Finder window.

You know what?: I think this was a left-over from a debugging-Finder. But they will leave it in :wink:

1 Like

Heck, that’s not a caveat, that’s a feature

:blush:

No, seriously, I think, this was a good tweak.
Who wants to see .DS_Store files?
Even Onyx will trash them.[1]

[1] Edit: Proposes to trash them

1 Like

Wow! That's great!