📄 vartrace.sh
字号:
#!/bin/bashtrap 'echo "VARIABLE-TRACE> \$variable = \"$variable\""' DEBUG# Echoes the value of $variable after every command.variable=29echo "Just initialized \"\$variable\" to $variable."let "variable *= 3"echo "Just multiplied \"\$variable\" by 3."exit $?# The "trap 'command1 . . . command2 . . .' DEBUG" construct is#+ more appropriate in the context of a complex script,#+ where placing multiple "echo $variable" statements might be#+ clumsy and time-consuming.# Thanks, Stephane Chazelas for the pointer.Output of script:VARIABLE-TRACE> $variable = ""VARIABLE-TRACE> $variable = "29"Just initialized "$variable" to 29.VARIABLE-TRACE> $variable = "29"VARIABLE-TRACE> $variable = "87"Just multiplied "$variable" by 3.VARIABLE-TRACE> $variable = "87"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -