1

In a fresh, clean bash instance I get as expected the following:

$ printf "a\td\n" | cat -vE
a   d$
$
$ file <(printf "a\td\n" | cat -vE)
/dev/fd/63: symbolic link to pipe:[6664004]

However I currently have a bash instance that returns:

$ printf "a\td\n" | cat -vE
a   d$
$
$ file <(printf "a\td\n" | cat -vE)
bash: syntax error near unexpected token `('
$
$ type -a printf
printf is a shell builtin
printf is /usr/bin/printf
printf is /bin/printf
$
$ type -a file
file is /usr/bin/file
file is /bin/file

What could be causing this error?

If I compare the environment variables, there is no significant difference with a fresh bash instance. Similarly, I see nothing special in the variables that currently exist in the session. Any clue?...

The Quark
  • 260
  • 1
  • 11

1 Answers1

1

I happened to have the variable POSIXLY_CORRECT set as I had earlier run set -o posix.

It was in my list of variables as POSIXLY_CORRECT=y but it did not occur to me at first sight that this could be the cause. (I was rather searching for any interference with the names of the commands.)

Resetting using set +o posix solved the problem.

ilkkachu
  • 133,243
  • 15
  • 236
  • 397
The Quark
  • 260
  • 1
  • 11
  • [another answer](https://unix.stackexchange.com/a/668265/170373) mentioned a while back that Bash 5.1 allows process substitutions even in POSIX mode. – ilkkachu Sep 19 '21 at 07:15
  • Note that running `sh -a` on systems where `sh` is bash is enough to set that `POSIXLY_CORRECT` environment variable (and all commands run within that sh session will be in POSIX mode). – Stéphane Chazelas Sep 19 '21 at 07:15
  • On my system (Linux Mint 20.2): `bash --version` > `GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)` – The Quark Sep 19 '21 at 07:35