Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posix shells don't have arrays #134

Open
slycordinator opened this issue Aug 25, 2023 · 0 comments
Open

Posix shells don't have arrays #134

slycordinator opened this issue Aug 25, 2023 · 0 comments

Comments

@slycordinator
Copy link

According to https://hyperpolyglot.org/shell#resizable-array-literal
POSIX shells have the ability to

  • create arrays with nums=(1 2 3 4)
  • check their size with ${#nums[@]}
  • lookup values with ${nums[0]}
  • update value with nums[1]=5
  • slice them with ${nums[@]:1:2}
  • concatenate them with c=(${a[@]} ${b[@]})
  • iterate over elements with
for i in ${nums[@]}
do echo $i
done

But each of these all will result in syntax errors in a POSIX shell, because arrays aren't defined in posix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant