E.g.
- Code: Select all
#!/bin/sh
declare -a Unix=('Debian' 'Red hat' 'Red hat' 'Suse' 'Fedora');
echo ${Unix[@]}
Fail with:
- Code: Select all
./array.sh: 3: ./array.sh: Syntax error: "(" unexpected
Why does this happen?
#!/bin/sh
declare -a Unix=('Debian' 'Red hat' 'Red hat' 'Suse' 'Fedora');
echo ${Unix[@]}
./array.sh: 3: ./array.sh: Syntax error: "(" unexpected



eanfrid wrote:Your default shell called by the symlink /bin/sh is not bash but dash (debian shell), hence the error message



eanfrid wrote:You can safely use any alternative you like.
eanfrid wrote:Regarding dash, check wikipedia: https://en.wikipedia.org/wiki/Debian_Almquist_shell



Users browsing this forum: No registered users and 13 guests