Sample Header Ad - 728x90

Why does BASH process substitution not work with some commands?

41 votes
1 answer
9015 views
On occasion process substitution will not work as expected. Here is an example: Input: gcc <(echo 'int main(){return 0;}') Output: /dev/fd/63: file not recognized: Illegal seek collect2: error: ld returned 1 exit status Input: But it works as expected when used with a different command: grep main <(echo 'int main(){return 0;}') Output: int main(){return 0;} I have noticed similar failures with other commands (i.e. the command expecting the file from the process substitution can't use /dev/fd/63 or similar). This failure with gcc is just the most recent. Is there some general rule that I should be aware of to determine when process substitution will fail in this way and should not be used? I am using this BASH version on Ubuntu 12.04 (I've also seen this in arch and debian): GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu)
Asked by Lotney (577 rep)
Oct 25, 2014, 12:00 AM
Last activity: Feb 14, 2025, 11:47 AM