# Local Variables and Getting a Value Back

local keeps a function's variables to itself, so it can't change the script's by accident; a function hands back a result by printing it with echo, which the caller catches with $( ), and answers yes or no with return, which if can test.

![Cheat sheet for the lesson Local Variables and Getting a Value Back: local keeps a function's variables to itself, so it can't change the script's by accident; a function hands back a result by printing it with echo, which the caller catches with $( ), and answers yes or no with return, which if…](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/7c2705aef64146d1ae5cf3fae0b8831e.webp)

- Category: Bash
- Level: Journeyman
- Tags: command-substitution, exit-code, global-variable, linux, local-variable, return, unix
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/bash-function-return-values-cheat-sheet
