Skip to content

Releases: paulmann/sr-search-replace

sr 7.0.1

Choose a tag to compare

@paulmann paulmann released this 12 Oct 02:21

sr 7.0.1

[7.0.1] - 2026-10-12

Release-engineering patch: fixes the pipeline defects that stopped v7.0.0
from producing a GitHub Release, and aligns the declared Python floor with
what the code has required since 7.0.0. No behavioural changes to sr
itself — same commands, same exit codes, same session format.

Fixed

  • The release workflow could never publish. It verified the built asset
    with sha256sum -c build/sr.pyz.sha256 from the repository root, but the
    checksum file names the asset bare (<digest> sr.pyz) and sha256sum -c
    resolves that name against the working directory — so the v7.0.0 release
    died with sr.pyz: No such file or directory. The step now runs the check
    from build/. The released asset pair itself was always correct: download
    sr.pyz and sr.pyz.sha256 into one directory and run
    sha256sum -c sr.pyz.sha256 there.
  • A CI gate line that could never pass. The checksum-name gate grepped
    the installer for ASSET = "sr.pyz" (with spaces) while
    scripts/install.sh has always said ASSET="sr.pyz". The gate now greps
    the real spelling and additionally pins the bare-name ↔ cd build pairing
    in the release workflow and the build tool.
  • The CI man-page comparison was a calendar time bomb. A raw diff -u
    included the generated .TH date line, so the gate only passed while the
    runner's date matched the day the page was committed. CI now uses
    build_manpage.py --check, which ignores the date.
  • The installer job relied on the runner image carrying pytest for its
    fail-closed updater gate; it now installs pytest explicitly.

Changed

  • Minimum Python is 3.10 (declared: 3.9 — and broken there). 7.0.0 used
    dataclass(slots=True), a 3.10 feature, in 36 places, so both 3.9 CI legs
    died during collection and a real 3.9 install would have failed on import.
    requires-python, the classifiers, the CI matrix (3.10/3.11/3.13/3.14 on
    Linux + macOS, 3.12 on Linux), install.sh, sr-cli, the npm launcher and
    sr doctor now declare the same floor, and a structural test keeps them
    from drifting apart again. Python 3.9 environments keep the 6.x Bash
    implementation from the v6.1.0 release assets.

Added

  • make workflow-check (tools/check_workflows.py) — the gate that was
    missing. It parses .github/workflows/*.yml, syntax-checks every run:
    block and executes the hermetic workflow steps verbatim, with the
    workflows' own environment, so a workflow line that disagrees with the
    repository fails locally before the push instead of on a runner after the
    tag. tests/test_workflows.py re-runs both steps that died on the
    v7.0.0 runners as regression tests.

Install

# standalone single file (no package manager)
curl -fsSL https://raw.githubusercontent.com/paulmann/sr-search-replace/main/scripts/install.sh | bash

# or
pipx install sr-search-replace
npm install -g sr-search-replace

Verify the download

sha256sum -c sr.pyz.sha256      # must print "OK"
sr selftest                     # end-to-end smoke test
sr doctor                       # environment and installation report

Update an existing standalone install

sr update --check
sr update

Full manual: sr help · Migration from 6.x: sr help compat

Search & Replace v6.1.0: Extended Regex, Tool Control & Enhanced Configuration

Choose a tag to compare

@paulmann paulmann released this 22 Dec 18:59

Release Notes: Search and Replace (sr) v6.1.0

Release Date: December 22, 2025
Version: 6.1.0
Status: Stable Release (Feature Enhancement)

🎉 Highlights

This feature-rich release introduces a powerful, extensible configuration system, direct tool parameter passing, and extended search capabilities, solidifying sr as the most configurable and precise search-and-replace utility for professional workflows. It maintains full backward compatibility with v6.0.0.

✨ Major Features

Enhanced Configuration & Extensibility

  • Tool-Specific Configuration Variables: Base commands (FIND_TOOL, SED_TOOL, GREP_TOOL) and default flags are now configurable script variables for unparalleled customization.
  • Direct Parameter Passing: New --find-opts, --sed-opts, and --grep-opts flags allow experts to pass raw arguments directly to the underlying utilities for maximum control.
  • Environment Variable Expansion: Dozens of new SR_* environment variables (e.g., SR_IGNORE_CASE, SR_FIND_FLAGS) provide fine-grained control over script behavior from the shell.

Advanced Search & Replace Capabilities

  • Extended Regular Expressions: Enable with -E or --extended-regex for more powerful pattern matching.
  • Case-Insensitive Operations: New -i or --ignore-case flag performs case-insensitive search and replace across all files.
  • Word Boundary Matching: The -w or --word-boundary flag ensures replacements only occur on whole words, preventing partial matches.
  • Multi-line & Global Control: New -m (multiline) and --no-global flags provide precise control over regex behavior and replacement scope.

Improved Compatibility & Diagnostics

  • GNU/BSD Sed Compatibility: Enhanced detection and handling of sed variations across platforms ensures consistent behavior.
  • Comprehensive Argument Analysis: The parsing engine now provides detailed debugging output for complex argument patterns and shell expansions.
  • Enhanced Performance Tracking: Detailed real-time statistics, including processing rate and file size analysis, are available in verbose and debug modes.

Robustness & Safety

  • Predictable Parsing Enhanced: The argument parser now intelligently detects shell-expanded file lists, supporting both sr *.txt *.js "search" "replace" and traditional pattern-based usage.
  • Enhanced Binary Protection: The safety-first default remains—binary files are always skipped unless explicitly allowed with the --binary flag.

📦 Installation & Dependencies

# Clone repository
git clone https://github.com/paulmann/sr-search-replace.git
cd sr-search-replace

# Make executable
chmod 755 sr.sh

# Install globally (optional)
sudo cp sr.sh /usr/local/bin/sr

New Core Dependency Note: sr relies on the standard Unix toolchain. For full v6.1.0 functionality (like binary detection), ensure file utility is installed (e.g., apt install file, brew install file).

🚀 Quick Start

# 1. Use new case-insensitive search for a code refactor
sr -i "src/**/*.py" "asyncOldFunc" "asyncNewFunc"

# 2. Pass custom flags to find for advanced filtering
sr --find-opts="-type f -mtime -1" "*.log" "ERROR" "WARNING"

# 3. Perform a safe, precise replacement on whole words only
sr -E -w "documentation.md" "\bAPI\b" "Application Programming Interface"

# 4. Preview complex multi-line changes
sr --dry-run -m "config.yaml" "server:\\n  host:.*" "server:\\n  host: prod.example.com"

# Restore from any backup (session system from v6.0.0)
sr --rollback

📋 Key New Options

Option Description
--find-opts="FLAGS" Pass additional flags directly to the find command.
--sed-opts="FLAGS" Pass additional flags directly to the sed command.
--grep-opts="FLAGS" Pass additional flags directly to the grep command.
-i, --ignore-case Perform case-insensitive search and replace.
-E, --extended-regex Use extended regular expressions (ERE).
-w, --word-boundary Match whole words only.
-m, --multiline Enable multi-line mode for regex matching.
--no-global Replace only the first occurrence in each line.
-n, --line-numbers Show line numbers in debug/output.

(All safety and core options from v6.0.0, like --dry-run, --rollback, -v, -d, remain fully supported.)

🔒 Safety Features

  • ✅ Backward Compatibility: All v6.0.0 scripts and commands work unchanged.
  • ✅ Explicit Binary Control: --binary flag still required to process binary files.
  • ✅ Session-Based Rollback: Full rollback system from v6.0.0 is unchanged and fully compatible.
  • ✅ Dry-Run Previews: Always test with --dry-run before making changes.
  • ✅ Configurable Safety Limits: Environment variables control depth, file size, and exclusions.

🐛 Bug Fixes & Improvements

  • Enhanced Argument Parsing: Robust handling of shell-expanded file lists and complex quoting scenarios.
  • Improved Debug Output: More detailed diagnostics for file discovery and binary detection steps.
  • Platform-Specific Fixes: Better handling of path names and permissions across Linux, macOS, and BSD.
  • Performance Optimizations: Reduced overhead in file metadata collection and session tracking.

🔐 Security Improvements

  • Path Sanitization: Strengthened validation of file paths during rollback and backup operations.
  • Tool Flag Validation: Basic sanitization of user-provided --*-opts flags to prevent injection.
  • Secure Defaults: The principle of least privilege is maintained; dangerous operations always require explicit flags.

📚 Documentation

  • README.md: Completely rewritten and expanded for v6.1.0, featuring new guides, workflow examples, and enterprise deployment patterns.
  • Updated In-Script Help: Comprehensive help text (sr --help) includes all new v6.1.0 options and examples.
  • Configuration Guide: Detailed comments in the script header explain all configurable variables.

📊 Performance

  • File Discovery: ~1000 files/second (optimized with new --find-opts).
  • Pattern Matching: Enhanced speed with compiled extended regexes.
  • Tool Overhead: Negligible impact from new configuration system.
  • Memory Usage: Efficient streaming processing for large files remains unchanged.

⚠️ Upgrade Notes

This is a non-breaking, additive release. No changes to existing workflows are required.

  • Users leveraging the new tool-specific flags (--find-opts, etc.) should be familiar with the underlying utilities (find, sed, grep).
  • Review new SR_* environment variables in the script header for system-wide customization.

🤝 Contributing

Contributions are welcome! Please ensure:

  1. Code follows the enhanced style conventions and uses the new configuration variables.
  2. All changes tested with the new -E, -i, and --dry-run options where applicable.
  3. Documentation is updated for new features.
  4. Backward compatibility with v6.0.0 is maintained.

📞 Support

📄 License

MIT License - See LICENSE file for details.


Made with ❤️ for developers and system administrators who demand precision and control.

Search & Replace (sr) v6.1.0: Configure, Extend, and Execute with Confidence.