linux参数调用参数设置,linux – 设置位置参数时使用 – 和 – 作为选项之间的区别...

4.1.5(1)的bash(1)手册页说:

-- If no arguments follow this option, then the positional

parameters are unset. Otherwise, the positional parame‐

ters are set to the args, even if some of them begin

with a -.

- Signal the end of options, cause all remaining args to

be assigned to the positional parameters. The -x and -v

options are turned off. If there are no args, the posi‐

tional parameters remain unchanged.

第一个区别是 – 或 – 之后没有参数.对于前者,现有的位置参数将保持不变.对于后者,将清除位置参数.

所以设置 – 清除位置参数和设置 – 是一个无操作.

-v和-x设置可以通过set修改 – ….所以,如果你设置-v打开(导致shell在读取时打印输入行),它将被设置关闭 – …命令.设置 – …将保持不变.

set -x更常见的是set -v在set -x中经常用于调试脚本以确切地查看正在运行的命令.通常在调试shell脚本时,您可以使用bash -x< script>运行它.知道set – …关闭-x,你可能想要使用set – …,因为将-x作为另一个命令的副作用关闭会非常意外.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值