Search⌘ K
AI Features

General Recommendations on Functions

Explore how to properly define and use functions in Bash by choosing clear names, using local variables with consistent naming, and passing parameters instead of global variables. Understand how to avoid naming conflicts with aliases and when to use the function keyword. This lesson helps you write cleaner, more reliable Bash scripts.

We'll cover the following...

We considered the functions in Bash. Here are general recommendations on how to use them:

  1. Choose names for your functions carefully. They should explain the purpose of the functions.

  2. Declare only local variables inside functions. Use some naming convention for them. This solves potential conflicts of local and global variable names.

  3. Do not use global ...