git子模块foreach:执行读取 [英] git submodule foreach: execute read

查看:184
本文介绍了git子模块foreach:执行读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在git foreach中执行读取?

Is it possible to execute a read inside a git foreach?

git submodule foreach 'read -p "test"; echo $REPLY'

根本不起作用,因为读取从git本身获取输入-这里是objname和哈希. 有没有机会以交互方式阅读控制台?

does not work at all as the read gets the input from git itself - which is the objname and hash here. Is there any chance to read interactively of the console?

推荐答案

如果将输入/输出重定向到/dev/tty,则可以.您将要首先使用基于 isatty的方法检查tty是否可用.当你做这种事情的时候.

You can if you redirect input/output to /dev/tty. You will want to check whether a tty is available with isatty based methods first when you do this kind of thing.

例如,像这样创建./test.sh

exec </dev/tty >/dev/tty
read -p "Enter text:" VALUE
echo "got: $VALUE"

然后

git submodule foreach ../test.sh

会做正确的事,例如在我的测试中

Will do the right thing, e.g. in my testing

sehe@meerkat:~/custom/MONO$ git submodule foreach ../test.sh
Entering 'cecil'
Enter text:a
got: a
Entering 'glib'
Enter text:b
got: b
Entering 'gtk-sharp'
Enter text:c
got: c
...

这篇关于git子模块foreach:执行读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆