Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Bourne-descended shells, as an unfortunate historical accident, if FOO is an array, then referring to FOO without a subscript is equivalent to referring to its zeroth element.

For your example,

  ${array:$from:$to}
is equivalent to

  ${array[0]:$from:$to}
And likewise

  $ FOO=(a b c d)
  $ FOO=x
  $ echo ${FOO}
  x
  $ echo ${FOO[@]}
  x b c d


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: