Sign in to follow this  

Bourne Shell Can't Use Arrays?

Recommended Posts

I was reading in my book that the bourne shell, sh, only supports scalar varaible, not arrays. I would expect the following to fail, but it works well

VAR=(aaa bbb)
echo ${VAR[1]}

isn't the above code a array variable, if so it should not work?

Share this post

Link to post
Share on other sites

I found this explanation. Only where bash and POSIX sh are incompatible, will /bin/bash interperet the code in a strict POSIX sh manner. That would explain why #!/bin/sh would run the code above.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this