1 # Sort the positional paramters.
2 # Make sure the positional parameters are passed as arguments to the function.
3 # If -u is the first arg, remove duplicate array members.
13 # if you want the case of no positional parameters to return success,
14 # remove the error message and return 0
16 echo "$FUNCNAME: argument expected" >&2
20 # make R a copy of the positional parameters
24 R=( $( printf "%s\n" "${R[@]}" | sort $u) )
26 printf "%s\n" "${R[@]}"
30 # will print everything on separate lines
31 set -- 3 1 4 1 5 9 2 6 5 3 2
34 # sets without preserving quoted parameters
35 set -- $( sort_posparams "$@" )
39 # sets preserving quoted parameters, beware pos params with embedded newlines
40 set -- 'a b' 'a c' 'x z'
44 set -- $( sort_posparams "$@" )