⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort-pos-params

📁 android-w.song.android.widget
💻
字号:
# Sort the positional paramters.# Make sure the positional parameters are passed as arguments to the function.# If -u is the first arg, remove duplicate array members.sort_posparams(){	local -a R	local u	case "$1" in	-u)	u=-u ; shift ;;	esac	# if you want the case of no positional parameters to return success,	# remove the error message and return 0	if [ $# -eq 0 ]; then		echo "$FUNCNAME: argument expected" >&2		return 1	fi	# make R a copy of the positional parameters	R=( "${@}" )	# sort R.	R=( $( printf "%s\n" "${R[@]}" | sort $u) )	printf "%s\n" "${R[@]}"	return 0}# will print everything on separate linesset -- 3 1 4 1 5 9 2 6 5 3 2sort_posparams "$@"# sets without preserving quoted parametersset -- $( sort_posparams "$@" )echo "$@"echo $## sets preserving quoted parameters, beware pos params with embedded newlinesset -- 'a b' 'a c' 'x z'oifs=$IFSIFS=$'\n'set -- $( sort_posparams "$@" )IFS="$oifs"echo "$@"echo $#sort_posparams

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -