Learn Tiny Core. View Tiny Core Screen Shots and Videos.
#!/bin/bashmain() { say_hi "$1" ; say_bye "$2" ; }say_hi() { echo "hi $1" ; }say_bye() { echo "bye $1" ; }# main "$@" (return 0 2>/dev/null) && { sourced=1;return 0; } || { main "${@}" ; }
(return 0 2>/dev/null)
for i in /proc/$$/fd/1* ; do echo "$i :$(readlink $i)" ; done
say_hi() { echo "hi $1" ; }say_bye() { echo "bye $1" ; }
when return is called out side of a functionit has the same effect as calling exit
#!/usr/bin/env -S busybox ashset -x this=$_;that=$0;q="$?"if (return 0 2>/dev/null); then echo "Script was sourced. \$? = $?"fifor i in /proc/$$/fd/1* ; do echo "$i :$(readlink $i)" ; done
main() { say_hi "$1" ; say_bye "$2" ; }say_hi() { echo "hi $1" ; }say_bye() { echo "bye $1" ; } for argx in "${@}" ; do case $argx in m|main) shift ; main "${@}" ; exit 0 ;; #s|i|'source'|import) shift ;; *) shift ;; # other args esac done # no args [ $# -eq 0 ] && return 0 ;