← 전체로 돌아가기
프로젝트 메모 linux -home-son-prj-log

User Config 파일, 정렬 금지

User config 파일, 정렬하면 주석 다 꼬임. 조심.

linuxconfigshellbest-practicesystem-admin

User config 파일 수정 시 정렬 금지. crontab, ssh config, hosts, shell rc 같은 user config 파일에 entry 추가할 때 sort, sort -u 같은 정렬 작업 절대 하지 마. dedupe 목적이라도 마찬가지.

왜? User crontab에 "Consolidated slot:" 같은 주석들이 특정 라인 바로 위에 붙어 있음. sort -u 돌리면 주석들 알파벳 순으로 다 흩어지고, 사람이 읽기 좋게 해둔 구조 다 망가짐. 사용자한테 지적받고 되돌림. wtf.

적용법: 기존 config에 라인 추가할 때 1. 원본 백업 먼저.

crontab -l > /tmp/cron.cur
  1. 새 entry는 맨 뒤에 빈 줄 하나 넣고 설명 주석과 함께 추가.
  2. 수정된 파일 그대로 설치. 정렬 절대 금지, reordering으로 dedupe도 금지.
  3. 진짜 dedupe 필요하면 직접 읽고 수정해야 함. sort -u로 퉁치지 마.

여기서 배울 것

  1. Config 파일은 주석 위치 중요함.
  2. `sort -u` 쓰면 주석 섞여서 엉망됨.
  3. 추가할 땐 백업 후 맨 뒤에 붙이기.
  4. Dedupe 필요하면 직접 수정해야 함.
원본 파일 보기 (.claude/projects/-home-son-prj-log/memory/feedback_no_sort_user_configs.md)
---
name: Never reorder user's config files when making edits
description: When modifying multi-line user configs (crontab, ssh config, etc.), append/edit in place — never sort or reorder, since comments are positionally meaningful
type: feedback
originSessionId: 8874cf71-b5b6-4745-b220-ecae855dfbce
---
When adding entries to user config files like crontab, ssh config, hosts files, or shell rc files, do NOT pipe through `sort`, `sort -u`, or any reordering operation — even when "deduplicating".

**Why:** User's crontab on this machine has carefully positioned comments (e.g., "Consolidated slot:" comment placed directly before the relevant cron lines). Running `sort -u` to dedupe scattered all comments alphabetically and broke the human-readable structure. User had to point out the regression for me to revert.

**How to apply:** When adding a line to an existing config:
1. Back up the original first (`crontab -l > /tmp/cron.cur`)
2. Append the new entry at the end with a blank line + descriptive comment
3. Install the modified file as-is — never sort, never dedupe via reordering
4. If dedup is genuinely needed, do it manually by reading and editing, not via `sort -u`