Yaro Kasear - 2021-06-07

I am trying to allow triggers to send text to notify-send in Linux. I
have tried a couple of different trigger /defs that have sort of worked
but not cleanly.

My first /def was:

/def -mregexp -F -t"(. says, .)" notify_say = /sys notify-send '
$[world_info()]' ' %P1'

This works until any apostrophe ' gets me the following errors:

sh: -c: line 1: unexpected EOF while looking for matching "' sh: -c: line 2: syntax error: unexpected end of file sh: -c: line 1: unexpected EOF while looking for matching"'

So, I tried to just replace every space, ', and " with escapes.

/def -mregexp -F -t"(. says, .)" notify_say = /sys notify-send '
$[world_info()]'  $[replace(" ", "\ ", replace('"', '\'\'', replace("'",
"\'", %P1)))]

This works in that I get the notification, except tinyfugue will vomit
the below at me even though the command did infact invoke notify-send
and give me my notification properly.

sh: -c: line 2: syntax error: unexpected end of file
sh: -c: line 1: unexpected EOF while looking for matching `"'
sh: -c: line 2: syntax error: unexpected end of file

Does anyone have a macro that auto-escapes stuff for sh in a way that tf
actually likes? I'm getting annoyed trying to figure out how to make a
string in tf it can use with /sys without upsetting sh -c.

Yaro