Chinaunix首页 | 论坛 | 博客
  • 博客访问: 310946
  • 博文数量: 214
  • 博客积分: 4258
  • 博客等级: 上校
  • 技术积分: 2021
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-02 09:16
个人简介

http://blog.csdn.net/ly21st http://ly21st.blog.chinaunix.net

文章分类

全部博文(214)

文章存档

2018年(16)

2015年(1)

2014年(2)

2012年(22)

2011年(173)

分类: Python/Ruby

2011-10-13 14:48:41

#!/bin/ksh
# Scriptname: do_increment
# 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 ? variable
print $sum          # The variable "sum" was local to the
                    # function, and is undefined in the main
                    # script. Nothing is printed.
                   
阅读(261) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~