⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ref-params.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# ref-params.sh: Dereferencing a parameter passed to a function.#                (Complex Example)ITERATIONS=3  # How many times to get input.icount=1my_read () {  #  Called with my_read varname,  #+ outputs the previous value between brackets as the default value,  #+ then asks for a new value.  local local_var  echo -n "Enter a value "  eval 'echo -n "[$'$1'] "'  #  Previous value.# eval echo -n "[\$$1] "     #  Easier to understand,                             #+ but loses trailing space in user prompt.  read local_var  [ -n "$local_var" ] && eval $1=\$local_var  # "And-list": if "local_var" then set "$1" to its value.}echowhile [ "$icount" -le "$ITERATIONS" ]do  my_read var  echo "Entry #$icount = $var"  let "icount += 1"  echodone  # Thanks to Stephane Chazelas for providing this instructive example.exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -