Reputation: 1
I am trying to understand why the script will work with #!/bin/bash
but not #!/bin/sh
. I am running Cygwin and both sh.exe
and bash.exe
seem to be identical (same file size).
$ cat 1.sh
#!/bin/sh
while read line; do
echo ${line:0:9}
done < <(help | head -5)
$ ./1.sh
./1.sh: line 4: syntax error near unexpected token `<'
./1.sh: line 4: `done < <(help | head -5)'
$ cat 2.sh
#!/bin/bash
while read line; do
echo ${line:0:9}
done < <(help | head -5)
$ ./2.sh
GNU bash,
These she
Type `hel
Use `info
Use `man
Upvotes: 0
Views: 3286
Reputation: 84443
Upvotes: 2
Reputation: 22481
Despite being same file, shell analyzes its own name when run and switches to either plain shell or bash mode.
Upvotes: 5