码迷,mamicode.com
首页 > 系统相关 > 详细

set -- 传递变量到shell 参数

时间:2018-10-23 21:04:10      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:val   --   tps   $1   .com   lin   following   OWIN   int   

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 参数

标签:val   --   tps   $1   .com   lin   following   OWIN   int   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!