首页 > 系统服务 > 详细

shell参数中空格

时间:2015-08-11 19:13:51      阅读:222      评论:0      收藏:0      [点我收藏+]

在使用shell传参数时。

解析参数时请不要用shift

 action="$1"

case "$action" in
    status)
        shift
        status$@
        exit $?
    ;;
    ...
     *)
        help
        exit -1
    ;;
esac

因为就算有双引号,也无法再次传递。

而是应该确定的按参数追逐个传递。

    status)
        status  $2 $3
        exit $?
    ;;


本文出自 “熊猫所罗” 博客,请务必保留此出处http://hotcache.blog.51cto.com/3404778/1683620

shell参数中空格

原文:http://hotcache.blog.51cto.com/3404778/1683620

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