Started övning 4, labb 6
This commit is contained in:
29
Labb6/test_func.sh
Executable file
29
Labb6/test_func.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Jack-Benny Persson
|
||||
# LX13
|
||||
# Testing functions
|
||||
|
||||
Nr1=$1
|
||||
Nr2=$2
|
||||
|
||||
# Sanity checks
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "`basename $0` requires two arguments (integers)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Functions
|
||||
add()
|
||||
{
|
||||
Sum=$((Nr1+Nr2))
|
||||
return $Sum
|
||||
}
|
||||
|
||||
# Main
|
||||
add
|
||||
echo $?
|
||||
echo "Nr1 contained ${#Nr1} chars, Nr2 contained ${#Nr2}"
|
||||
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user