Process Substitution not working with Linux 2 bash?

0

Does the bash provided with AWS Linux 2 not support process substitution? I have never used this feature previously, but now a circumstance has come up where it would be useful. But even the simplest demo fails, e.g.:

me$ cat <(date)
sh: syntax error near unexpected token `('

My shell say it's:

GNU bash, version 4.2.46(2)-release-(x86_64-koji-linux-gnu)

And fwiw my shell in /etc/passwd is /bin/bash, and anyway /bin/sh is just a symlink to /bin/bash.

Am I missing something? Or is Linux 2 really delivered with a bash that doesn't support this?

asked 4 years ago536 views
3 Answers
0

Hello,

me$ cat <(date)

Is a bash-ism. Bash is not 100% compatible with the POSIX sh standard. So even if it is a symlink, bash will behave differently when executed from `sh

bash-4.2# cat <(date)
Mon Oct 5 20:53:23 UTC 2020
bash-4.2# sh
sh-4.2# cat <(date)
sh: syntax error near unexpected token `('
sh-4.2# bash
bash-4.2# cat <(date)
Mon Oct 5 20:53:33 UTC 2020
bash-4.2#

This seems to be some form of compatibility/compliance mode. Make sure your shell (or script #! / shebang) is the "normal" bash and not /bin/sh if you plan to use bash specific features.

Edited by: Emmanuel-aws on Oct 5, 2020 1:56 PM

answered 4 years ago
0

I understand what you are saying here, however:

  1. My shell really is bash, as I stated originally. Both "bash --version" and "sh --version" identify themselves to bash, as I quoted.

  2. shebang does not enter into the question; It doesn't work right from the shell prompt either.

answered 4 years ago
0

Still, that gave me the clue I needed. Thanks!

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions