I do this in a script:
read direc <<< $(basename `pwd`)
and I get:
Syntax error: redirection unexpected
On my machine, if I run a script directly, the default is bash.
bash
If I run it with sudo, the default is sh.
sudo
sh
That’s why I was hitting this problem when I used sudo.