Skip to content

[plan] Fix SC2012: Replace ls with find in 41 workflows #7898

@github-actions

Description

@github-actions

Objective

Fix 72 occurrences of shellcheck SC2012 info-level issues across 41 workflows by replacing ls parsing with find commands for more robust filename handling.

Problem

Using ls output in scripts can fail with special characters in filenames (spaces, newlines, etc.):

ls -t *.yml | head -5  # ❌ Breaks with spaces/special chars

Solution

Use find with proper formatting:

find . -name "*.yml" -type f -printf '%T@ %p\n' | sort -rn | head -5 | cut -d' ' -f2

Impact

While info-level, this improves robustness when:

  • Filenames contain spaces or special characters
  • Operating in directories with varied file naming conventions
  • Processing user-generated or external files

Approach

  1. Identify all ls usage patterns in workflow .md files
  2. Determine the intent of each ls command (sorting, filtering, etc.)
  3. Replace with equivalent find commands
  4. Test locally if possible for common patterns
  5. Recompile workflows: make recompile
  6. Verify with actionlint

Common Patterns to Fix

# Pattern 1: List by time
ls -t pattern | head -n    → find + sort + head

# Pattern 2: List all files
ls pattern                  → find -name pattern

# Pattern 3: List with size
ls -lh pattern             → find -printf with custom format

Files to Modify

41 workflow .md files in .github/workflows/ (72 total occurrences)

Acceptance Criteria

AI generated by Plan Command for discussion #7889

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions