我正在尝试制作 ffcast屏幕转换工具 bash 4.1 向后兼容。
并在此 ffcast.bash脚本,有一行
shopt -s extglob lastpipe
lastpipe 选项仅在 bash 4.3 之后可用,我该怎么做才能模拟其效果?
最佳答案
lastpipe
(顺便说一下,在 bash 4.2 中引入)只能通过不使用管道来模拟。您需要在当前 shell 中显式运行管道的最后一个命令,并从进程替换中重定向其输入
# foo | bar | baz becomes ...
baz < <(foo | bar)
或命名管道(也符合 POSIX 标准)
# foo | bar | baz becomes ...
mkfifo baz_input
foo | bar > baz_input &
baz < baz_input
关于bash - `shopt -s lastpipe` 如何影响 bash 脚本行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36340599/