set -- 传递变量到shell 参数
Posted uxiuxi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了set -- 传递变量到shell 参数相关的知识,希望对你有一定的参考价值。
set --
The --
is the standard "don‘t treat anything following this as an option" 不把后面的string 看成选项(直接看成参数)
[[email protected] ~]# cat set2.sh
#!/bin/bash
var="1 2 3"
echo $var
set -- $var #do not treat - as option ,only take $var as $1 $2 ..
i=1
while [ "$i" -le $# ]
do
echo -n "$$i = " #do not change line
eval echo $$i
(( i ++ )) # same as let i=i+1
done
set --
echo "$1 = $1"
echo "$2 = $2"
echo "$3 = $3"
[[email protected] ~]#
https://unix.stackexchange.com/questions/308260/what-does-set-do-in-this-dockerfile-entrypoint
以上是关于set -- 传递变量到shell 参数的主要内容,如果未能解决你的问题,请参考以下文章
Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数