ruby - 在 Ruby shell 脚本中运行 OS X `say` 命令而不退出

标签 ruby macos bash shell

如何在 Ruby shell 脚本中运行 OS X 命令 say ( man page ),而不退出该脚本?帖子中的建议Calling shell commands from Ruby似乎不适用。

最佳答案

你想要

`say "#{var_name}"`

如果您发现反引号难以阅读

%x(say "#{var_name}")

这也可以工作:

system "say", var_name

关于ruby - 在 Ruby shell 脚本中运行 OS X `say` 命令而不退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26898937/

相关文章:

python - 在 python 脚本中调用 bash 函数

ios - 在 MAC 和 iOS 中收听文件更新

javascript - 安装 npm 包 weexpack 时校验和验证失败

ruby-on-rails - 索引中 instance_variable 的 RSpec

ruby-on-rails - 须藤标准输出 : unicorn_appname_production: unrecognized service

ruby-on-rails - Rails - 如何创建字母系统?

python-3.x - python3.7 pip install mysqlclient 失败,错误为 'Building wheel for mysqlclient (setup.py) ... error'

android - adb pull 在 bash 脚本中的奇怪行为

linux - bash中只接受一定范围内的输入

ruby - to_specs':在 [] 中找不到 Chef (>= 0)(Gem::LoadError)