加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何默认Ruby“gem clean”命令的[Yn]响应?

发布时间:2020-12-17 03:35:19 所属栏目:百科 来源:网络整理
导读:我经常使用 Ruby gem clean命令来保持本地gem存储库的形状. 但是,由于依赖性问题,该命令多次返回一个提示,例如: XXXXX-1.0.6 depends on [YYYYYY (~ 0.8.4)]If you remove this gems,one or more dependencies will not be met.Continue with Uninstall? [Y
我经常使用 Ruby gem clean命令来保持本地gem存储库的形状.

但是,由于依赖性问题,该命令多次返回一个提示,例如:

XXXXX-1.0.6 depends on [YYYYYY (~> 0.8.4)]
If you remove this gems,one or more dependencies will not be met.
Continue with Uninstall? [Yn]

虽然这很简单,但它需要手动干预(对于[Yn]响应),因此这使我无法创建一个简单的cron脚本来自动执行此过程.

有关如何默认响应这些gem提示的任何想法?

解决方法

你应该有一个yes命令,OSX版本有这个说:

YES(1)                    BSD General Commands Manual                   YES(1)

NAME
     yes -- be repetitively affirmative

SYNOPSIS
     yes [expletive]

DESCRIPTION
     yes outputs expletive,or,by default,``y'',forever.

HISTORY
     The yes command appeared in 4.0BSD.

4th Berkeley Distribution        June 6,1993        4th Berkeley Distribution

所以也许这会奏效:

yes n | gem clean

gem clean可能是直接从终端读取而不是标准输入.在这种情况下,你可能会期待踢:

Expect is a program that “talks” to other interactive programs according to a script. Following the script,Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition,the user can take control and interact directly when desired,afterward returning control to the script.

因此,您可以根据需要编写一个expect脚本,以“y”或“n”响应预期的提示.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读