12
为什么要在函数中编写整个bash脚本?
在工作中,我经常编写bash脚本。我的主管建议将整个脚本分解为功能,类似于以下示例: #!/bin/bash # Configure variables declare_variables() { noun=geese count=three } # Announce something i_am_foo() { echo "I am foo" sleep 0.5 echo "hear me roar!" } # Tell a joke walk_into_bar() { echo "So these ${count} ${noun} walk into a bar..." } # Emulate a pendulum clock for a bit …