mysql的哪个set是什么意思_请问这个命令是什么意思 set -- mysqld ?

set -- 后无内容,将当前 shell 脚本的参数置空,$1 $? $@ 等都为空。

set -- 后有内容,当前 shell 脚本的参数被替换为 set -- 后的内容,$1 $? $@ 等相应地被改变。

举例

//文件 tmp.sh

#!/bin/sh

#set -- aa ss dd

echo $0 #命令行

echo $1 #第一个参数

echo $* #所有参数

echo $@ #所有参数

echo $# #命令行参数个数

执行./tmp.sh qq ww ee的输出

./tmp.sh

qq

qq ww ee

qq ww ee

3

去掉set --前的注释#,执行./tmp.sh qq ww ee的输出

./tmp.sh

aa

aa ss dd

aa ss dd

3

一点线索

mysql 的 DOCKFILE

在看 mysql 的 DOCKFILE 怎么写时,也看到了相同的写法如下:

mysql/5.7/docker-entrypoint.sh

# if command starts with an option, prepend mysqld

if [ "${1:0:1}" = '-' ]; then

set -- mysqld "$@"

fi

ps: ${1:0:1} =》 ${parameter:offset:length}

set 的 man page

查到 set 的 man page 中有对 -- 有如下介绍

set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]

set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]

-- If no arguments follow this option, then the positional parameters are unset. Otherwise, the positional parameters are set to the args, even if some of them begin with a -.

名词解释

Positional parameters in a shell script are nothing but the command line arguments passed to a shell script.

它啥也不是,就是指的 shell 脚本的参数

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值