I have a script with a long list of OPTIONAL arguments. some have associated values.
Such as:
.script --first 2012-12-25 --last 2012-12-26 --copy --remov
$@ is an array, & not a simple variable.
You can capture it to a local variable as x=("$@") & then use array x with indices as 0 to ($# - 1).
To access individual elements, use ${x[$i]}. You can NOT directly use ${@[$i]}, however.
So instead of for arg in "$@" loop, you will have i=0; while [ $i -lt $# ]; do loop.