首页 > 系统服务 > 详细

set -- 传递变量到shell 参数

时间:2018-10-23 20:01:55      阅读:183      评论:0      收藏:0      [点我收藏+]

set --

 

The -- is the standard "don‘t treat anything following this as an option"   不把后面的string 看成选项(直接看成参数)

[root@hy ~]# 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"

[root@hy ~]#

 

https://unix.stackexchange.com/questions/308260/what-does-set-do-in-this-dockerfile-entrypoint

set -- 传递变量到shell 参数

原文:https://www.cnblogs.com/uxiuxi/p/9838395.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!