是否有可能在msys/mingw上模拟进程替换(使用bash 3.x) [英] Is it possible to mimic process substitution on msys /mingw (with bash 3.x)
问题描述
我正在尝试使用进程替换来避免使用临时文件.我尝试了以下方法:
I am trying to use process substitution to avoid using temporary files. I tried the following:
diff <(echo "a") <(echo "b")
在mingw32/msys上(截至2013年12月,摘自 http://www.mingw.org/) ,并得到:
on mingw32/msys (from http://www.mingw.org/ as of Dec 2013), and got:
sh: syntax error near unexpected token `('
在Ubuntu 12.04上运行相同的操作会返回:
Running the same thing on Ubuntu 12.04 returns:
1c1
< a
---
> b
我使用的msys可能具有bash 3.1.我想知道是否有可能解决此问题,以便无需使用临时文件就可以在msys/older bash中完成相同的工作.
The msys I use probably has bash 3.1. I was wondering if it is possible to work around the issue so that the same job can be done in msys/older bash without using temporary files.
谢谢.
推荐答案
我准备在bash 3.x中进行进程替换.语法正确.它由bash shell支持.因此,我建议检查一下您正在运行的shell并执行以下命令:
I mananed to do process substitution in bash 3.x. The syntax is correct. It is supported by bash shell. So I would suggest to check what shell your are running and execute somiting like:
/bin/bash diff <(echo "a") <(echo "b")
进程替换不是POSIX兼容功能.要启用尝试运行:
Process substitution is not a POSIX compliant feature. To enable try to run:
set +o posix
另请参阅此.
另一种方法是使用命名管道.我在GNU bash版本4.1.2(1)上进行了测试:
The other way is to use named pipes. I tested on GNU bash version 4.1.2(1):
diff - p <<< "test" & echo "test2" > p
请参阅使用命名管道
这篇关于是否有可能在msys/mingw上模拟进程替换(使用bash 3.x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!