If I do:
set a b c
How do I access the last element of $@, namely c?
I've initially thought to subscript the $@ array:
"${@[$#-1]}"
But:
bash: ${@[$#-1]}: bad substitution
I eventually came up with:
eval echo "\$$#"
Is there a way to get the last element of $@ without eval?
Is the only way to first copy it to another array and access ${copy[-1]}?