#!/bin/bash
if [ $# -le 0 ]
then
echo "error"
exit 0
fi
sum=0
while [ $# -gt 0 ]
do
sum=`expr $sum + $1`
shift
done
echo 'sum='$sum
if [ $# -le 0 ]
then
echo "error"
exit 0
fi
sum=0
while [ $# -gt 0 ]
do
sum=`expr $sum + $1`
shift
done
echo 'sum='$sum
echo '$#='$#
hero@ubuntu:~/xuexi$ ./j 1 2 3 4 5
sum=15
$#=0
hero@ubuntu:~/xuexi$