What is the best way to detect, from a KM macro, the locale (
$LC_CTYPE) setting in a users's Terminal.app
/bin/bash settings ?
(not the same as the LC_TYPE value in KM's
Execute shell script
The character count given by the bash
wc -m filename in a Keyboard Maestro
Execute a shell script action can differ significantly from that given by
wc -m in Terminal.app, and this means that scripts which work well in Terminal.app may behave incorrectly in Keyboard Maestro.
This is because the user's default
/bin/bash locale (like the path settings in their .bash_profile) are not exported to KM's slightly different
In particular, $LC_CTYPE might have the value "UTF-8" in Terminal.app, but have the value "C" in the KM '/bin/sh', and this will mean that
wc -m in Keyboard Maestro simply falls back to the same return value as
wc -c – making no allowance for multi-byte characters.
I would like to detect the Terminal.app setting, and export it into the KM /bin/sh context.
Any thoughts on a clean solution ?