Pass values to case statement in a function korn shell

I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it?

ie

function1 () {
case
opt1 do .....
opt2 do.....
esac
}

function opt1

I'm aware the syntax is not correct, but you get the general idea.

function function1() {
case $1 in
        1) do something ;;
        2) do other something ;;
        [3-9]) do some other something ;;
esac
}

call it with function1 $opt1

1 Like