Complete AI TrainingYourJobSkills for your job

Skills / super-code

bash

Language-specific super-code guidelines for bash.

new

Bash / Shell: Idiomatic Efficiency Reference

When to Use

  • Use this skill when the task matches this description: Language-specific super-code guidelines for bash.

Table of Contents

  1. [Quoting & Word Splitting](#quoting)
  2. [Conditionals & Tests](#conditionals)
  3. [Loops & Iteration](#loops)
  4. [Pipes & Process Substitution](#pipes)
  5. [Functions & Return Values](#functions)
  6. [Error Handling](#errors)
  7. [Anti-patterns specific to Bash](#antipatterns)

1. Quoting & Word Splitting {#quoting}

# ❌ Unquoted variable (word splitting + globbing)
for f in $files; do rm $f; done

# ✅
for f in "${files[@]}"; do rm -- "$f"; done
# ❌ Unquoted command substitution
path=$(find . -name config)
cat $path  # breaks on spaces

# ✅
path="$(find . -name config)"
cat "$path"
# ❌ Using backticks for command substitution
result=`echo hello`

# ✅ — $() nests cleanly
result=$(echo hello)
# ❌ String comparison without quotes
if [ $var = "hello" ]; then  # breaks if var is empty or has spaces

# ✅
if [[ "$var" = "hello" ]]; then

Rule: double-quote every $variable and $(command) unless you specifically need splitting.


2. Conditionals & Tests {#conditionals}

# ❌ Single bracket test (POSIX but fragile)
if [ -f "$file" -a -r "$file" ]; then

# ✅ — [[ is safer, supports &&/||, no word splitting inside
if [[ -f

Subscribers only

The full skill, its 1 bundled files and every download is included with every paid Complete AI plan.

Details

Sourcecommunity
License
Risk labelsafe ("critical" means the skill may run commands or touch files — read before use)
FilesSKILL.md
Added2026-06-16

Related skills

c

Language-specific super-code guidelines for c.

cpp

Language-specific super-code guidelines for cpp.

csharp

Language-specific super-code guidelines for csharp.

dart

Language-specific super-code guidelines for dart.

elixir

Language-specific super-code guidelines for elixir.

go

Language-specific super-code guidelines for go.