diferença entre sh e bash quando o symlink é usado
Eu tenho um script de shell que usaprocess substitution
O script é:
#!/bin/bash
while read line
do
echo "$line"
done < <( grep "^abcd$" file.txt )
Quando eu executo o script usandosh file.sh
Eu recebo a seguinte saída
$sh file.sh
file.sh: line 5: syntax error near unexpected token `<'
file.sh: line 5: `done < <( grep "^abcd$" file.txt )'
Quando eu executo o script usandobash file.sh
, o script funciona.
Curiosamente,sh
é umsoft-link
mapeado para/bin/bash
.
$ which bash
/bin/bash
$ which sh
/usr/bin/sh
$ ls -l /usr/bin/sh
lrwxrwxrwx 1 root root 9 Jul 23 2012 /usr/bin/sh -> /bin/bash
$ ls -l /bin/bash
-rwxr-xr-x 1 root root 648016 Jul 12 2012 /bin/bash
Eu testei para ter certeza de que os links simbólicos estão sendo seguidos no meu shell usando o seguinte:
$ ./a.out
hello world
$ ln -s a.out a.link
$ ./a.link
hello world
$ ls -l a.out
-rwx--x--x 1 xxxx xxxx 16614 Dec 27 19:53 a.out
$ ls -l a.link
lrwxrwxrwx 1 xxxx xxxx 5 May 14 14:12 a.link -> a.out
Eu não consigo entender porquesh file.sh
não executa como/bin/bash file.sh
Desde ash
é um link simbólico para/bin/bash
.
Qualquer insight será muito apreciado. Obrigado.