更新时间:2023-12-05 08:18:04
从 /dev/tty
获取 perl 脚本重定向输入.
Have the perl script redirect input from /dev/tty
.
概念证明:
while read line ; do
export line
perl -e 'print "Enter $ENV{line}: ";$y=<STDIN>;print "$ENV{line} is $y\n"' </dev/tty
done <<EOF
foo
bar
EOF
程序输出(粗体的用户输入):
Program output (user input in bold):
输入 foo:123foo 是 123
输入栏:456酒吧是 456
Enter foo: 123
foo is 123
Enter bar: 456
bar is 456