$ cat bin/say #!/usr/bin/env ruby class String # return this string in qoutes def quote return '"' + self + '"' end # copied from file lib/shellwords.rb, line 69 # escapes a string according to sh rules def shellescape str = self return "''" if str.nil? # added by nailor # An empty argument will be skipped, so return empty quotes. return "''" if str.empty? str = str.dup # Process as a single byte sequence because not all shell # implementations are multibyte aware. str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1") # A LF cannot be escaped with a backslash because a backslash + LF # combo is regarded as line continuation and simply ignored. str.gsub!(/\n/, "'\n'") return str end def asciify return self.tr("^A-Za-z0-9_.\-", "_") end end if ARGV.length < 1 STDERR.puts "need an argument" Process.exit(-1) end text = ARGV.join(" ") text = text.shellescape p text system "echo #{text} | espeak -v de --stdin --stdout | aplay"