Greg Brown Greg Brown - 1 year ago 118
Bash Question

Qt Creator - How to run program with cmd line arguments involving process substitution

I am trying to run my program from Qt Creator with command line options involving process substitution. Here's the command (I want each line written to file to be prepended with the time and date, achieved by, while the output to the terminal remains unchanged):

$ exec | tee >( > output.txt)

However, I get the error

/bin/sh: -c: line 0: syntax error near unexpected token `('

My default shell is bash and the SHELL variable in my run environment is also /bin/bash. This command works if I execute the program from the terminal but not when launched in Qt Creator.

Answer Source

Process substitution is a feature of bash, whereas QtCreator is apparently hardcoded to use sh to execute the run command. You can inject bash into your command as follows:

$ exec | bash -c 'tee >( > output.txt)'