Process unusual filenames safely in a shell pipeline
8 steps · about 2 h 40 min · Intermediate
- Recognize unsafe filename expansion (guide, ShellCheck Wiki, 24 min)
See how unquoted expansion splits and expands pathname data before a command receives it.
- Emit paths from a standards-based traversal (reference, The Open Group Base Specifications, 18 min)
Understand the portable find expression model before adding implementation-specific null output.
- Protect filenames that begin with a dash (guide, ShellCheck Wiki, 18 min)
Use an explicit path prefix or option boundary so a pathname cannot be interpreted as a command option.
- Quote shell expansions correctly (guide, GNU Bash manual, 22 min)
Prevent word splitting, glob expansion and syntax interpretation when a pathname becomes an argument.
- Use option boundaries and target directories (guide, GNU Coreutils manual, 18 min)
Keep a leading dash in a filename from becoming an option and make multi-file destinations explicit.
- Batch arguments within system limits (reference, The Open Group Base Specifications, 18 min)
Use the standard utility model to stay inside argument-size limits and interpret exit behavior.
- Bound parallel file processing (reference, GNU Parallel documentation, 20 min)
Add concurrency only with an explicit limit and a command safe to run independently.
- Review traversal and word-splitting hazards (guide, ShellCheck Wiki, 22 min)
Use a static-analysis warning to identify loops that break unusual names and hide command failures.