1 Star 1 Fork 0

pengqing/python-web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
parse_yml.sh 685 Bytes
一键复制 编辑 原始数据 按行查看 历史
熊小鹏 提交于 2023-03-09 14:48 +08:00 . feat: add parse yml shell
#!/bin/bash
# 用法 parse_yaml 文件名.yml
function parse_yaml {
local prefix=$2
# shellcheck disable=SC2155
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
# shellcheck disable=SC1087
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xiongxiaopeng/python-web.git
git@gitee.com:xiongxiaopeng/python-web.git
xiongxiaopeng
python-web
python-web
master

搜索帮助