Use single quotes for terminal notifier notifications to avoid variable expansion

This commit is contained in:
James Booth
2015-02-14 16:20:15 +00:00
parent 9951da0c8f
commit c9a6e10c26

View File

@@ -243,10 +243,9 @@ _notify(const char * const message, int timeout,
Shell_NotifyIcon(NIM_MODIFY, &nid); Shell_NotifyIcon(NIM_MODIFY, &nid);
#endif #endif
#ifdef HAVE_OSXNOTIFY #ifdef HAVE_OSXNOTIFY
GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message \""); GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '");
char *escaped_double = str_replace(message, "\"", "\\\""); char *escaped_single = str_replace(message, "'", "'\\''");
char *escaped_single = str_replace(escaped_double, "`", "\\`");
if (escaped_single[0] == '<') { if (escaped_single[0] == '<') {
g_string_append(notify_command, "\\<"); g_string_append(notify_command, "\\<");
@@ -264,8 +263,7 @@ _notify(const char * const message, int timeout,
g_string_append(notify_command, escaped_single); g_string_append(notify_command, escaped_single);
} }
g_string_append(notify_command, "\""); g_string_append(notify_command, "'");
free(escaped_double);
free(escaped_single); free(escaped_single);
char *term_name = getenv("TERM_PROGRAM"); char *term_name = getenv("TERM_PROGRAM");
@@ -288,4 +286,4 @@ _notify(const char * const message, int timeout,
g_string_free(notify_command, TRUE); g_string_free(notify_command, TRUE);
#endif #endif
} }