# Call function from script from CLI

Blogeintrag auf baeldung.com
https://www.baeldung.com/linux/run-function-in-script
To call functions from inside a shell script from the CLI, you could try to source the script. But this means that all variables and commands get loaded into your current session.
To prevent this, write a case check like the following.

#!/bin/bash

func1() {
	# code you want to call from the CLI
}

func1() {
	# code you want to call from the CLI
}

case "$1" in
    func1) "$@"; exit;;
    func2) "$@"; exit;;
    *) echo "unknown fn $1"; exit;;

esac