Menu

#14 Check for anything to do with arrays

open
nobody
None
5
2017-08-30
2017-08-30
mcandre
No

Arrays are bashisms, lol. Attempting to access a variable as somevar[@] (for-loop form), or somevar[*] (string joining form), represents bash syntax, whereas POSIX sh has not even an array type.

Source:

http://www.etalabs.net/sh_tricks.html

Discussion

  • mcandre

    mcandre - 2017-08-30

    (I spoke too early in this comment about treating some things like for, $@, and $* as bashisms.)

     

    Last edit: mcandre 2017-08-30
  • mcandre

    mcandre - 2017-08-30

    Note that the for keyword is NOT a bashism. The for loop has been in POSIX sh for some time, though it can only be used with an array literal or with $@ (implicit when the "in foo bar baz" part is omitted), not with any kind of array variable.

    $@ is not a bashism.

    $* is not a bashism.

    ${@:someinteger} and "${@:someinteger}" ARE bashisms, as bare POSIX sh does not features these shift shorthand convenience forms.

     

    Last edit: mcandre 2017-08-30

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.