From 02f3505cd6d585a24d79cca033f30ce88e972563 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 21 Jun 2014 14:27:05 -0700 Subject: Escape phrases before 'say'ing them in OS X --- client/speaker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/speaker.py b/client/speaker.py index f2d4ab7..e7dc075 100644 --- a/client/speaker.py +++ b/client/speaker.py @@ -22,8 +22,11 @@ class MacSpeaker: def isAvailable(cls): return os.system("which say") == 0 + def shellquote(self, s): + return "'" + s.replace("'", "'\\''") + "'" + def say(self, phrase): - os.system("say " + phrase) + os.system("say " + self.shellquote(phrase)) def playSound(self, filename): os.system("afplay " + filename) -- cgit v1.3.1