Shell Script Error: Line 1: defaults: command not found

I just 'updated' the great PNG Optimizer by @Tom
I had to re-install a couple 'parts' of it. While doing so, something got broken under the hood. I'm not strong with shell script stuff etc etc, any help would be appreciated.

When I run the following shell script:

defaults write com.stairways.keyboardmaestro.engine DisplayLargeTextDisplayPeriod -float $KMVAR_Large_Display_Time

I get the following KM response:

What happens when you run this instead:

/usr/bin/defaults write com.stairways.keyboardmaestro.engine DisplayLargeTextDisplayPeriod -float $KMVAR_Large_Display_Time

in terminal runs fine,
in KM no display error

While updating the PNG Optimizer, I had to change the variable
ENV_PATH to /usr/local/bin to get it to work

What does “no display error” mean?

You get an error that says “no display” or you don’t get any display error im KM (whatever this is)?

sorry for that: I do not get any display after running the shell script you provided within KM.
Which is good

You don’t have to change that variable by replacing paths. You can append or prepend paths to the already existing ones (separated by :).

Try this as ENV_PATH:

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

LOL - you're crazy helpful Tom, really, thank you.
Works for my 'old' shell scripts and also the PNG Optimizer.
made my morning, thank you - !!!

Great that it works now.

The new path (from my post above) means that the KM shell now first looks into /usr/local/bin (that’s where most of the user-installed binaries are located), and then into /usr/bin (where for example defaults is located, and other standard binaries).
And then the remaining paths, of course.

The order is important for cases where you have two different versions of the same program installed. For example the standard version that comes with macOS (in /usr/bin or /bin), and a newer version you installed yourself (usually in /usr/local/bin).
With the order as above the shell uses the version in /usr/local/bin, which normally is what you want.

1 Like