~优化实现

This commit is contained in:
juewuy
2026-01-26 19:08:06 +08:00
parent 21366a0667
commit 215fc29c35

View File

@@ -1,9 +1,6 @@
#参数1代表变量名参数2代表变量值,参数3即文件路径 #参数1代表变量名参数2代表变量值,参数3即文件路径
setconfig() { setconfig() {
[ -z "$3" ] && configpath="$CRASHDIR"/configs/ShellCrash.cfg || configpath="${3}" [ -z "$3" ] && configpath="$CRASHDIR"/configs/ShellCrash.cfg || configpath="${3}"
if grep -q "^${1}=" "$configpath"; then sed -i "/^${1}=.*/d" "$configpath"
sed -i "s#^${1}=.*#${1}=${2}#g" "$configpath" printf '%s=%s\n' "$1" "$2" >>"$configpath"
else
printf '%s=%s\n' "$1" "$2" >>"$configpath"
fi
} }