do_increment

来自「Advanced Bash&#8722 Scripting Guide An 」· 代码 · 共 21 行

TXT
21
字号
#!/bin/ksh# Script name: increment# Example 10.122# Using the return Command)function increment {    typeset sum       # sum is a local variable.    (( sum = $1 + 1 ))    return $sum       # Return the value of sum to the script.} print -n "The sum is "increment 5     # Call the function increment and pass 5 as a                # parameter. 5 becomes $1 for the increment                 # function.print $?        # The return value is stored in the ? variableprint $sum      # The variable "sum" was local to the                 # function, and is undefined in the main                 # script. Nothing is printed.

⌨️ 快捷键说明

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