I apologize for the vagueness but I'm trying to learn some shell scripting--NOTE: currently on line ~200 of 10,000--but I sort of hit a wall with "lists/arrays". From what I can tell from some of the reading resources I found is that /bin/sh does not have a list so-to-speak.
Basic support:
The above works but at this point in the post, I will use some hybrid syntax (sorry) to demonstrate my goal.
From sh(1) I see a brief on "lists" with curly braces (but I obviously need a slightly better explanation than that because I'm making a mess here).
From my test something like this isn't possible.
Question:
1. What is "{ item; }" intended use etc?
2. Can I create a named array/list?
2a. Can I evaluate each item in a list?
Sub question/request: if there is any sort of "good resource" you like, please post.
Basic support:
Bash:
#! /bin/sh
set -- 1 \
2 \
3
# print each item in list...
#for item in "$@"; do echo "$item"; done
# add items to list
set -- "$@" 4 \
5 \
6 \
7
# print each item in list...
for item in "$@"; do echo "$item"; done
The above works but at this point in the post, I will use some hybrid syntax (sorry) to demonstrate my goal.
From sh(1) I see a brief on "lists" with curly braces (but I obviously need a slightly better explanation than that because I'm making a mess here).
From my test something like this isn't possible.
Bash:
#! /bin/sh
dog={
mkdir -p ./test/level1;
mkdir -p ./test/level2;
}
cat={
mkdir -p ./test/level3;
mkdir -p ./test/level4;
}
set -- $dog
# ... decision, condition, etc.
set -- "$@" $cat
# eval each item in list
for item in "$@"; do $item; done
Question:
1. What is "{ item; }" intended use etc?
2. Can I create a named array/list?
2a. Can I evaluate each item in a list?
Sub question/request: if there is any sort of "good resource" you like, please post.