@peternlewis do you have any advice on obtaining line delimiters from TokenText fields in custom plugins ?
I’m not sure how line endings are encoded in
$KMPARAM_ – values passed to the shell script by these fields.
A Bash line like:
echo $KMPARAM_New_items | tr '\n\r' 'x'
[\n\r] at the end of the whole variable, but none between any separate lines that were entered in the TokenText plugin field.
PS I’ve tried C-Quoting with printf, which sort of works, but then things like 汉子 and get scrambled.
PS it is entirely possible that there is a solution which I am missing, but I think that for the moment, when I need both:
- Multi-line data, and
- utf8 characters
I will design plugins to specify the name of a variable holding that data, rather than expanding a variable text token in a TokenText field.
Having to go through Bash variables to get from plugin field to macro logic seems to make multiline utf8 a little bit tricky. Eludes me, anyway : - )
(Easier to use an application .getvariable method to read the multline utf8 directly, evading the bash stage)
Keyboard Maestro preserves the line endings (typically linefeeds) and passes them to the environment of NSTask.
But it appears by the time they get through NSTask into the environment, the linefeeds have been changed to spaces. I’m surprised this has never come up before, but it does not appear to be new.
Looks like an odd choice in NSTask to me, but it does not appear to be anything I can work around - the best I can suggest would be to either encode the line endings somehow beforehand, or save it to a file and pass that.
Thanks ! It’s very helpful to have that picture - will save me from charging at windmills : - )