[TODO]: Check and replace existing sed substitute statements with sedfile wrapper

Đang mở
#4,059 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@casperklein đang làm issue này rồi.

Từ ngày 9/6/2024.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

area/scripts kind/improvement meta/help wanted stale-bot/ignore
Subject

Something else that requires developers attention

Description
Description

This task is available for anyone that wants to tackle it.


sed substitution statements like sed -i 's/foo/bar/' somefile fail silently, when foo is not found.

This can lead to problems, when a file changed and the search pattern is not found anymore. If there is no explicit test for that, this bug will be unnoticed, until someone reports a problem, that is later tracked down to a sed statement, which no longer took place anymore.

Solution

The wrapper sedfile can replace sed -i [<other options>] <pattern> <file> statements. It checks the file before and after the substitution attempt. If no change is detected, it fails.

More information:

# Wrapper for 'sed -i': fail if file was not modified by sed and container was not restarted.
# Error output is suppressed, when container is restarted to avoid harmless error messages.
# Use "--strict" as first parameter, to fail regardless of the container state (fresh or restarted).

# When to use sedfile?
# Is a file change optional? --> use regular 'sed -i'
# Is a file change expected? --> use 'sedfile --strict -i'
# Is a file change only on the first container run expected? --> use 'sedfile -i'
Example
# Old
sed     -i 's/^discard-all-mails=true/discard-all-mails=false/' important.config

# New
sedfile -i 's/^discard-all-mails=true/discard-all-mails=false/' important.config
Todo

Evaluate all sed substitution statements and check, if an sedfile wrapper usage makes sense.

Ngôn ngữ chính
Shell
Star
19.7k
Fork
2.1k
Merge trung bình
22 giờ 39 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của docker-mailserver/docker-mailserver

Tất cả issue của docker-mailserver/docker-mailserver

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.