Here is mine solution:
- pretty portable (all POSIX sh, bash, ksh, zsh) should work
- does not shift original arguments (shifts a copy).
- does not use
evileval
- does not iterate through the whole list
- does not use external tools
Code:
ntharg() {
shift $1
echoprintf $1'%s\n' "$1"
}
LAST_ARG=`ntharg $# "$@"`