fork download
  1. #!/bin/bash
  2. Function addem
  3. {
  4. If [ $# -eq 0 ] || [ $# -gt 2 ]
  5. then
  6. echo -1
  7. elif [ $# -eq 1 ]
  8. then
  9. echo $[ $1 + $1 ]
  10. else
  11. echo $[ $1 + $2 ]
  12. fi
  13. }
  14. echo –n “adding 10 and 15:
  15. value=$(addem 10 15)
  16. echo $value
Success #stdin #stdout 0.03s 26052KB
stdin
Standard input is empty
stdout
Function addem
{
If [ $# -eq 0 ] || [ $# -gt 2 ]
then
 echo -1
elif [ $# -eq 1 ]
then
 echo $[ $1 + $1 ]
else
 echo $[ $1 + $2 ]
fi
}
echo –n “adding 10 and 15:”
value=$(addem 10 15)
echo $value