Search code examples
bashshsunos

Using <<< throws error on sh shell not in bash


In Sh

[SunOs] /opt # sh
[\h] \w \$ read -a array <<< "1 2 3";echo ${array[1]}
syntax error: `<' unexpected

In Bash

[SunOs] ~ # bash
[SunOs] ~ # read -a array <<< "1 2 3";echo ${array[1]}
2

Why the Error thorwn in "sh" shell, i'm using SunOS 5.10 Generic_147440-10 sun4v sparc sun4v


Solution

  • Herestrings aren't supported in sh.

    This causes the error when you try to run it using sh.