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 --- boot/test.py | 1 - client/speaker.py | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boot/test.py b/boot/test.py index 4c79f39..b390d5e 100644 --- a/boot/test.py +++ b/boot/test.py @@ -5,7 +5,6 @@ if os.environ.get('JASPER_HOME') is None: import sys import unittest -from sets import Set from mock import patch import vocabcompiler 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