Shell 的语法学习笔记二时间:2021-11-02 21:36:13笔记二 函数 1 #!/bin/sh 2 3 yes_or_no() { 4 echo "Is your name $* ? /n" 5 while true 6 do 7 echo -n "Enter yes or no: " 8 read x 9 case "$x" in 10 y | yes ) return 0;; 11 n | no ) return 1;; 12 esac 13 done 14 } 15 16 echo "Original parameters are $*" 17 18 if yes_or_no "$1" 19 then 20 echo "Hi $1, nice name" 21 else 22 echo "Never mind" 23 fi 24 25 exit 0 ~ export $1, $2... $()与`` expr