#!/bin/sh

funkce () {
	echo "funkce() {"
	printf "\tG == $G\n"
	G='ZEVNITR'
	printf "\tG=$G\n"
	echo "}"
}


# FUNKCE
echo '===== FUNKCE ====='
G='ZVENKU'
printf "G=$G\n"
funkce
printf "G == $G\n"
echo

# { }
echo '===== { } ====='
G='ZVENKU'
printf "G=$G\n"
{
	echo "{"
	printf "\tG == $G\n"
	G='ZEVNITR'
	printf "\tG=$G\n"
	echo "}"
}
printf "G == $G\n"
echo


# ( )
echo '===== ( ) ====='
G='ZVENKU'
printf "G=$G\n"
(
	echo "("
	printf "\tG == $G\n"
	G='ZEVNITR'
	printf "\tG=$G\n"
	echo ")"
)
printf "G == $G\n"
echo

# child process

# konstrukce <<"EOF" je here-document bez expanze promennych
cat > test.sh <<"EOF"
#!/bin/sh
echo "test.sh"
printf "\tG == $G\n"
G='ZEVNITR'
printf "\tG=$G\n"
EOF
chmod +x test.sh

echo '===== child process ====='
G='ZVENKU'
printf "G=$G\n"
./test.sh
printf "G == $G\n"
echo

echo '===== export & child process ====='
export G='ZVENKU'
printf "G=$G\n"
./test.sh
printf "G == $G\n"
echo
