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 …