Return code 101

Dig into your terminal and create the following Bash script:

#!/bin/bashGLOBAL_RET=255function my_function_global() {    ls /home/${USER}/.bashrc    GLOBAL_RET=$?}function my_function_return() {    ls /home/${USER}/.bashrc    return $?}function my_function_str() {    local UNAME=$1    local OUTPUT=""    if [ -e /home/${UNAME}/.bashrc ]; then        OUTPUT='FOUND IT'    else        OUTPUT='NOT FOUND'    fi    echo ${OUTPUT}}echo "Current ret: ${GLOBAL_RET}"my_function_global "${USER}"echo "Current ret after: ${GLOBAL_RET}"GLOBAL_RET=255echo "Current ret: ${GLOBAL_RET}"my_function_return "${USER}"GLOBAL_RET=$?echo "Current ret after: ${GLOBAL_RET}"# And for giggles, we can pass back output too!GLOBAL_RET=""echo "Current ret: ${GLOBAL_RET}"GLOBAL_RET=$(my_function_str ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.