问题描述
我正在尝试使 ffcast 屏幕投射工具bash 4.1向后兼容.
I am trying to make ffcast screen casting tool bash 4.1 backwards compatible.
,并在此 ffcast.bash 脚本中,有一条线
and in this ffcast.bash script, there is oneline
shopt -s extglob lastpipe
lastpipe选项仅在bash 4.3之后可用,我该如何模拟它的效果?
lastpipe option is only available after bash 4.3, what can I do to emulate its effect?
推荐答案
lastpipe
(顺便说一下,在bash 4.2中引入)只能通过不使用管道来模拟.您需要在当前Shell中显式运行管道的最后一条命令,然后从任一过程替换中重定向其输入
lastpipe
(introduced in bash 4.2, by the way) can only be simulated by not using a pipe. You need to explicitly run the last command of the pipe line in the current shell, and redirect its input from either a process substitution
# foo | bar | baz becomes ...
baz < <(foo | bar)
或命名管道(也符合POSIX)
or a named pipe (which is POSIX-compliant as well)
# foo | bar | baz becomes ...
mkfifo baz_input
foo | bar > baz_input &
baz < baz_input
这篇关于"shopt -s lastpipe"如何影响bash脚本行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!