我正在挖掘mysql_safe(试图添加一些选项),我遇到了这种用于从Launch Agent分配变量的bash脚本技术:com.mysql.mysqld.plist(我在mac上).
现在mysqld_safe不知道它是由LaunchCtl调用的,所以我假设任何选项都是由LaunchCtl转换成命令行参数,但我发现这个sytnax入侵了.谁知道这是如何工作的?
我理解Bash中Case/Switch的基础知识:
case "$myval" in
switch1) do something;;
switch2) do something;;
*) do whatever fallthrough logic;;
esac
Run Code Online (Sandbox Code Playgroud)
默认情况下通过使用*在下面的脚本块中,arg值是:" - baseased ="或"--datadir ="或"--pid-file ="等等但是什么与*in那里?
这是Switch语句中的正则表达式吗?
有一个后卫?
for arg do
# the parameter after "=", or the whole $arg if no match
val=`echo "$arg" | sed -e 's;^--[^=]*=;;'`
# what's before "=", or the whole $arg if no match
optname=`echo "$arg" | sed -e 's/^\(--[^=]*\)=.*$/\1/'`
# replace "_" by "-" ; mysqld_safe must accept "_" like mysqld does.
optname_subst=`echo "$optname" …Run Code Online (Sandbox Code Playgroud)