Zsh Shell Tutorial 11: Functions — Arguments, Return Values & Scope

18views
00
9:31
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Learn how to write functions in Zsh! In this lesson, we cover basic function syntax (shorthand and function keyword), passing arguments with positional parameters, return values and output capture, and local variable scope. 🕐 Timestamps: 0:00 - Introduction 0:25 - Basic Functions Explained 0:55 - Basic Functions Demo 2:17 - Function Arguments Explained 2:45 - Function Arguments Demo 4:07 - Return Values Explained 4:37 - Return Values Demo 6:04 - Local Variables Explained 6:32 - Local Variables Demo 7:59 - Recap 8:31 - End 📚 What you will learn: • Define functions with shorthand greet() or function keyword • Pass arguments using $1, $2, $@, and $# • Return status codes with return (0 = success, 1 = failure) • Capture function output with $() command substitution • Use the local keyword to protect variable scope • Avoid accidental global variable overwrites 💻 Source code: https://github.com/GoCelesteAI/zsh_functions 🔗 Full playlist: Zsh Shell Tutorial Series #zsh #shell #terminal #functions #scripting #tutorial #programming #linux #macos
Back to tutorials

Duration

9:31

Published

February 14, 2026

Added to Codegiz

March 15, 2026

Open in YouTube