I’m trying to append content from the argument list ("$@"), excluding $1 and also any value starting with a dash, to an array in bash.
My current code follows, but doesn’t operate correctly:
BuildTypeList=("armv7" "armv6")
BuildTypeLen=${#BuildTypeList[*]}
while [ "$2" != "-*" -a "$#" -gt 0 ]; do
BuildTypeList["$BuildTypeLen"] = "$2"
BuildTypeLen=${#BuildTypeList[*]}
shift
done
My intent is to add content to BuildTypeList at runtime, rather than defining its content statically as part of the source.
It’s simpler to just iterate over all the arguments, and selectively append them to your list.