Gakho
Gakho

Reputation: 673

Is there an equivalent to bash's <() in sh

I'm trying to a node.js program that redirects to bash. The command contains a string like this.

var virtualFile  = '<( cat <<EndOfText\n' + fileContents + 'EndOfText\n)';

However, when I redirect it, the sh freaks out at that text, before running bash.

I was wondering if '<()' has an equivalent in sh. Thanks

Upvotes: 0

Views: 55

Answers (1)

rici
rici

Reputation: 241861

If you are using process substitution (<(...)) to create a named pseudo-file which you can provide on the command line to a utility which also reads its stdin, then you should seriously consider just putting the contents (fileContents) into a temporary file. On most modern systems, that will turn out to be reasonably performant. Its other advantages are that it is easy and compatible with all shells, not only those that try to be Posix-compatible.

On the other hand, if you just need to feed fileContents into a utility and you can use stdin for that purpose, then you've got way too much machinery. Just use the here-doc itself ('<<EndMarker\n' + fileContents + 'EndMarker\n')

Upvotes: 1

Related Questions