ShixiangWang / self-study

My Self-Study Room: keep tidy and lightweight
https://shixiangwang.github.io/self-study/
30 stars 6 forks source link

golang 实现check命令 #64

Open ShixiangWang opened 3 years ago

ShixiangWang commented 3 years ago

对每个输入的shell脚本检查变量并逐一输出值,另外进行空值检查和提示

ShixiangWang commented 3 years ago

shcheck

ShixiangWang commented 3 years ago
( set -o posix ; set ) >/tmp/variables.before
source script
( set -o posix ; set ) >/tmp/variables.after
diff /tmp/variables.before /tmp/variables.after
rm /tmp/variables.before /tmp/variables.after

https://stackoverflow.com/questions/1305237/how-to-list-variables-declared-in-script-in-bash

ShixiangWang commented 3 years ago

zsh

( setopt posixbuiltin; set; )

https://askubuntu.com/questions/275965/how-to-list-all-variables-names-and-their-current-values