#!/bin/sh tu0(){ local local_var='local_var' global_var='global_var' foo() { printf 'foo()\n' printf 'local_var: %s\n' "${local_var}" printf 'global_var: %s\n' "${global_var}" } } tu0 tu1(){ bar() { printf 'bar()\n' printf 'local_var: %s\n' "${local_var}" printf 'global_var: %s\n' "${global_var}" } } tu1 main() { foo bar } main "${@}"