Skip to content

Instantly share code, notes, and snippets.

@adoyle-h

adoyle-h/t.bash Secret

Created July 2, 2019 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adoyle-h/c52d778b9b01c183d0eb41aa16892177 to your computer and use it in GitHub Desktop.
Save adoyle-h/c52d778b9b01c183d0eb41aa16892177 to your computer and use it in GitHub Desktop.
another return
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s inherit_errexit
readonly true=1
readonly false=0
return() {
case $1 in
0|true)
echo true ;
builtin return 0
;;
1|false)
echo false ;
builtin return 1
;;
*)
echo $1 ;
builtin return $1 ;;
esac
}
is_success() {
return false
}
foo() {
local a
a=$(is_success)
echo "$a"
}
foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment