<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bash 스크립트 &#8211; WONIZZ.LOG</title>
	<atom:link href="https://blog.wonizz.com/tag/bash-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.wonizz.com</link>
	<description>AI 자동화를 직접 굴려 본 개발자의 실무 교훈</description>
	<lastBuildDate>Mon, 05 Oct 2026 23:03:01 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-siteicon-512.png?fit=32%2C32&#038;ssl=1</url>
	<title>bash 스크립트 &#8211; WONIZZ.LOG</title>
	<link>https://blog.wonizz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">152411368</site>	<item>
		<title>[AI 코딩] 클로드 코드 되돌리기, 종료 코드 0인데 백업이 빠졌다</title>
		<link>https://blog.wonizz.com/2026/10/06/claude-code-script-safe-edit/</link>
					<comments>https://blog.wonizz.com/2026/10/06/claude-code-script-safe-edit/#respond</comments>
		
		<dc:creator><![CDATA[워니즈]]></dc:creator>
		<pubDate>Mon, 05 Oct 2026 23:03:01 +0000</pubDate>
				<category><![CDATA[AI & LLM]]></category>
		<category><![CDATA[AI 코딩]]></category>
		<category><![CDATA[bash 스크립트]]></category>
		<category><![CDATA[클로드 코드]]></category>
		<category><![CDATA[클로드 코드 되돌리기]]></category>
		<guid isPermaLink="false">https://blog.wonizz.com/?p=4102</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>클로드 코드 되돌리기로 파일은 돌아와도 돌고 있던 셸 스크립트가 이미 실행한 단계는 돌아오지 않습니다. 설명 줄 28바이트를 지우자 백업 단계가 빠지고 종료 코드 0이 나온 재현과 사본, bash -n, mv 로 바꾼 규칙을 정리했습니다.</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2026/10/06/claude-code-script-safe-edit/">[AI 코딩] 클로드 코드 되돌리기, 종료 코드 0인데 백업이 빠졌다</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>돌고 있는 셸 스크립트에서 설명 줄 28바이트를 지웠을 뿐인데 백업 단계가 빠지고 원본 지우기가 실행됐고, 종료 코드는 0이었습니다(2026-10-01, macOS 27.0, bash 5.3.20 재현). 이럴 때 클로드 코드 되돌리기로 파일을 돌려도 이미 실행된 단계는 돌아오지 않습니다.</p>
<p>안녕하세요? 정리하는 개발자 워니즈입니다. 앞 글 <a href="https://blog.wonizz.com/?p=4093">클로드 코드 멀티 에이전트, 거짓 6건 뒤 나눈 역할</a>에 이어, 9월 26일 실제로 겪은 스크립트 덮어쓰기와 빈 폴더에서 다시 돌린 실험 네 개를 정리합니다.</p>
<ul>
<li><strong>무엇을 했나</strong> 클로드 코드 되돌리기(/rewind)는 파일 내용을 돌려놓는 기능이고, 저는 돌고 있는 bash 스크립트를 실행 중에 고치는 실험 A~D 를 돌렸습니다</li>
<li><strong>결과 숫자</strong> 28바이트 삭제는 종료 코드 0으로 백업을 건너뛰었고, 22바이트 추가는 종료 코드 2로 멈췄으며, 사본에 고쳐 <code>mv</code> 로 바꾸자 세 단계가 모두 돌았습니다</li>
<li><strong>누구에게 쓸모</strong> 크론처럼 주기적으로 도는 셸 스크립트를 AI 에게 고치게 하는 분께 맞습니다</li>
</ul>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>고치는 방법</th>
<th>돌던 실행에 닿나</th>
<th>클로드 코드 되돌리기 기록</th>
<th>결과</th>
</tr>
</thead>
<tbody>
<tr>
<td>셸 명령으로 제자리 편집(<code>></code>, python <code>open(w)</code>)</td>
<td>닿음(같은 inode)</td>
<td>기록하지 않음</td>
<td>백업 건너뜀(0) 또는 문법 오류(2)</td>
</tr>
<tr>
<td>Edit 도구, <code>sed -i</code>, <code>perl -pi</code></td>
<td>안 닿음(새 inode)</td>
<td>Edit 도구만 기록</td>
<td>돌던 실행은 옛 판본 그대로</td>
</tr>
<tr>
<td>사본에 고치고 <code>bash -n</code> 뒤 <code>mv</code></td>
<td>안 닿음(새 inode)</td>
<td>해당 없음</td>
<td>세 단계 모두 실행, 다음 실행부터 새 판본</td>
</tr>
</tbody>
</table>
</figure>
<h2 id="s1">1. 클로드 코드 되돌리기 전에, 왜 종료 코드 0이었나요?</h2>
<p>bash 가 스크립트를 한꺼번에 읽지 않고 실행하면서 다음 위치를 바이트로 기억해 이어 읽는 것처럼 움직였기 때문입니다. 빈 폴더의 여섯 줄짜리 <code>deploy.sh</code>(준비, 백업, 원본 지우기를 echo 로만 찍는 모형)를 돌려 두고 1초 뒤 맨 위 설명 줄을 지우자 출력이 <code>[1] 준비</code> 다음 <code>[3] 원본 지우기</code> 로 끝났습니다. 오류는 한 줄도 없었습니다. <strong>결과가 가장 나쁜 경우가 신호는 가장 조용했습니다.</strong><br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/01-terminal-exp-a.png?w=1200&#038;ssl=1" alt="클로드 코드 되돌리기 실험 A의 repro.log 실제 출력, 준비 다음 백업 만들기 없이 원본 지우기가 찍히고 종료 코드는 0" /><br />
정직하게 덧붙이면, 지운 줄을 다음 백업 줄과 같은 28바이트로 일부러 맞췄습니다. 길이가 어긋난 실험 B(문구 22바이트 추가)는 한글 글자 한가운데부터 읽혀 종료 코드 2로 멈췄습니다. 흔한 쪽은 B 이고, A 는 운이 나쁘면 오류 없이 엉뚱한 단계가 돈다는 데까지만 보여 줍니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/02-vs-ab.png?w=1200&#038;ssl=1" alt="66번째 바이트 위치 대비, 실험 A는 28바이트가 줄어 원본 지우기 줄이 오고 실험 B는 22바이트가 늘어 한글 글자 한가운데가 되는 것을 보여주는 다이어그램" /></p>
<h2 id="s2">2. 어떤 고치기가 같은 inode 에 다시 쓰나요?</h2>
<p><code>></code> 리다이렉트와 python <code>open(w)</code> 가 같은 inode 에 다시 쓰고, <code>sed -i ''</code>, <code>perl -pi</code>, 사본 뒤 <code>mv</code>, Claude Code 2.1.281 Edit 도구는 새 inode 를 만들었습니다(<code>ls -i</code> 실측, 표는 부록). 돌던 bash 를 깨는 것은 같은 inode 쪽입니다. Edit 도구 결과는 한 버전에서 한 번 본 값이라 일반화하지 않습니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/03-timeline-inode.png?w=1200&#038;ssl=1" alt="고치기 방법 7가지의 inode 번호 변화, 리다이렉트와 python open(w)만 같은 inode를 유지하고 나머지는 새 inode로 바뀌는 것을 보여주는 타임라인" /><br />
9월 26일 실제 사고도 이 차이로 막았습니다. <code>lsof -p PID</code> 로 돌던 프로세스가 옛 inode 를 쥔 것을 보고, 백업을 <code>cat 백업 > 원본</code> 으로 같은 inode 에 되돌린 뒤 새 판본은 <code>mv</code> 로 넣었습니다. 권한을 줄 때 되돌릴 수 있다고 믿는 비용은 <a href="https://blog.wonizz.com/2026/08/03/ai-agent-permission-recovery-cost/">AI 에이전트 권한 설계와 되돌리기 비용</a>에 적었습니다.</p>
<h2 id="s3">3. 클로드 코드 되돌리기(/rewind)는 어디까지 되돌리나요?</h2>
<p>Claude 의 파일 편집 도구로 고친 파일까지입니다. 공식 문서는 체크포인트가 &#8220;Checkpointing does not track files modified by Bash commands.&#8221; 라고 적고, 버전 관리를 대신하지 않는다고 못 박습니다(<a href="https://code.claude.com/docs/en/checkpointing" target="_blank" rel="noopener">Claude Code checkpointing 공식 문서</a>). 가장 위험한 셸 명령 편집이 가장 되돌리기 어려운 편집이기도 했습니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/04-cards-rewind-menu.png?w=1200&#038;ssl=1" alt="클로드 코드 되돌리기(/rewind) 메뉴 항목 정리, 공식 문서 기준 Restore code and conversation, Restore conversation, Restore code, Summarize from here, Summarize up to here, Never mind와 Bash로 바뀐 파일은 추적하지 않는다는 문장" /><br />
원본 지우기는 파일이 아니라 이미 일어난 행동이라 /rewind 로 파일을 돌려도 지워진 것은 그대로입니다. 그래서 되돌리기를 믿을 만하게 만드는 대신 고치는 순서를 바꿨습니다.</p>
<h2 id="s4">4. 사본에 고치고 bash -n 뒤 mv 로 바꾸면 무엇이 달라지나요?</h2>
<p>실험 A 와 똑같이 설명 줄을 지우되 사본 <code>deploy.sh.new</code> 에서 고치고 <code>bash -n</code> 통과 뒤 <code>mv</code> 로 넣자, inode 가 6015892 에서 6015932 로 바뀌었고 돌던 프로세스는 옛 판본의 세 단계를 종료 코드 0으로 끝까지 실행했습니다. 편집 내용은 같고 원본에 닿는 방식만 바꿨는데 백업이 살아 있었습니다.<br />
<img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/05-steps-copy-swap.png?w=1200&#038;ssl=1" alt="원본을 그대로 두고 사본에 고친 뒤 bash -n이 통과하면 mv로 바꿔 넣고, 돌던 프로세스는 옛 판본을 끝까지 읽는 5단계 흐름" /></p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>상황</th>
<th>하는 일</th>
</tr>
</thead>
<tbody>
<tr>
<td>주기적으로 도는 셸 스크립트를 고친다</td>
<td>사본에 고치고 <code>bash -n</code> 통과 뒤 <code>mv</code></td>
</tr>
<tr>
<td>시각만 바꿔 한 번 돌려 본다</td>
<td>원본은 그대로, 사본을 돌림</td>
</tr>
<tr>
<td>이미 실행 중에 덮어썼다</td>
<td><code>lsof -p PID</code>, <code>cat 백업 > 원본</code>, 새 판본은 <code>mv</code></td>
</tr>
<tr>
<td>파이썬 스크립트</td>
<td>규칙 대상에서 뺌(실행 중 고치기 실험은 안 함, 미확인)</td>
</tr>
</tbody>
</table>
</figure>
<p><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/10/06-cards-decision.png?w=1200&#038;ssl=1" alt="상황별로 고르는 복구 방법, 주기적으로 도는 셸 스크립트는 사본+bash -n+mv, 한 번만 돌려볼 때는 사본 실행, 파이썬 스크립트는 규칙 대상 아님, 이미 실행 중 덮어썼다면 lsof+백업 복구를 보여주는 카드" /></p>
<h2 id="s5">5. 이렇게 해도 안 되는 것은 무엇인가요?</h2>
<ol>
<li>이미 실행된 단계는 어떤 되돌리기로도 돌아오지 않아, 지워질 대상은 git 이나 별도 백업으로 지킵니다</li>
<li><code>bash -n</code> 은 문법만 보고 단계 순서를 잘못 바꾼 판본은 통과시킵니다</li>
<li>9월 25일 여러 번 제자리 편집하고도 무사했던 이유, /rewind 가 같은 inode 에 쓰는지, zsh 나 다른 bash 판의 동작은 확인하지 않았습니다</li>
<li>세 줄은 작업 규칙이지 게이트가 아닙니다. 규칙과 지켜짐이 다른 이야기라는 것은 <a href="https://blog.wonizz.com/2026/08/17/ai-rules-need-gates/">AI에게 규칙을 알려줬는데 안 지켜졌습니다</a>에서 겪었습니다</li>
</ol>
<h3>필자의 결론</h3>
<blockquote><p>
클로드 코드 되돌리기는 파일을 돌리는 도구이고, 돌고 있는 스크립트의 사고를 막는 도구는 아닙니다.
</p></blockquote>
<blockquote><p>
주기적으로 도는 셸 스크립트는 사본에 고치고 <code>bash -n</code> 통과 뒤 <code>mv</code> 로 바꾸세요.
</p></blockquote>
<blockquote><p>
오늘은 그런 스크립트 하나에 <code>ls -i</code> 를 찍어 두고, 다음에 고친 뒤 번호가 바뀌었는지만 확인해 보세요.
</p></blockquote>
<p>돌고 있는 스크립트를 고칠 때 다른 방식으로 막고 계신 분은 어떤 순서를 쓰시나요?</p>
<h2 id="s6">부록: 재현 명령과 출력</h2>
<ol>
<li><strong>환경.</strong> 2026-10-01 밤, macOS 27.0, <code>GNU bash, 버전 5.3.20(1)-release (aarch64-apple-darwin27.0.0)</code>, <code>mktemp -d</code> 로 만든 /tmp 빈 폴더. <code>deploy.sh</code> 는 1 <code>#!/bin/bash</code>, 2 <code># 옛 설명</code>(공백으로 28바이트), 3 <code>echo "[1] 준비"</code>, 4 <code>sleep 3</code>, 5 <code>echo "[2] 백업 만들기"</code>, 6 <code>echo "[3] 원본 지우기"</code>.</li>
<li><strong>실험 A 명령과 출력.</strong></li>
</ol>
<pre class="wp-block-code"><code class="language-bash">bash deploy.sh > a.out 2>&1 & P=$!; sleep 1
python3 -c "p='deploy.sh'; s=open(p).read(); open(p,'w').write(s.replace(s.splitlines(True)[1],''))"
wait $P; echo "종료 코드 $?"; cat a.out</code></pre>
<pre class="wp-block-code"><code class="language-text">== 실험 A: 실행 중에 맨 위 설명 줄 하나를 지운다(제자리 편집)
종료 코드 0
[1] 준비
[3] 원본 지우기</code></pre>
<ol>
<li><strong>실험 B 출력</strong>(3번 줄을 <code>echo "[1] 준비 (설명을 늘렸다)"</code> 로 늘림).</li>
</ol>
<pre class="wp-block-code"><code class="language-text">종료 코드 2
[1] 준비
deploy.sh: 줄 5: 예기치 않은 `)' 토큰 주변에서 문법 오류
deploy.sh: 줄 5: `� 늘렸다)"'</code></pre>
<ol>
<li><strong>66번째 바이트 계산.</strong> 줄 길이는 12, 28, 18, 8, 28, 28바이트라 백업 줄은 66번째 바이트에서 시작합니다. 28바이트를 지우면 그 자리에 원본 지우기 줄이 오고, 22바이트를 넣으면 그 자리가 <code>을</code> 의 세 번째 바이트입니다(<code>repro.sh</code> 문자열을 <code>python3 -c</code> 로 셈).</li>
<li><strong>inode 실측</strong>(<code>repro-inode.log</code>, <code>ls -i</code>).</li>
</ol>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>고치기 방법</th>
<th>inode 번호</th>
<th>앞 단계와 비교</th>
</tr>
</thead>
<tbody>
<tr>
<td>처음 만든 파일</td>
<td>6020480</td>
<td>기준</td>
</tr>
<tr>
<td><code>sed -i ''</code></td>
<td>6020481</td>
<td>새 inode</td>
</tr>
<tr>
<td><code>perl -pi</code></td>
<td>6020482</td>
<td>새 inode</td>
</tr>
<tr>
<td><code>></code> 리다이렉트</td>
<td>6020482</td>
<td>같은 inode</td>
</tr>
<tr>
<td>python <code>open(w)</code></td>
<td>6020482</td>
<td>같은 inode</td>
</tr>
<tr>
<td>사본 만들고 <code>mv</code></td>
<td>6020484</td>
<td>새 inode</td>
</tr>
<tr>
<td>Claude Code 2.1.281 Edit 도구</td>
<td>6020314 에서 6020348 로</td>
<td>새 inode(대화형으로 따로 확인)</td>
</tr>
</tbody>
</table>
</figure>
<ol>
<li><strong>실험 C 명령과 결과.</strong></li>
</ol>
<pre class="wp-block-code"><code class="language-bash">cp deploy.sh deploy.sh.new
# 여기서 deploy.sh.new 를 고친다
bash -n deploy.sh.new && echo "bash -n 통과" && mv deploy.sh.new deploy.sh; ls -i deploy.sh</code></pre>
<p>바꾸기 전 6015892, <code>bash -n</code> 통과, 바꾼 뒤 6015932, 돌던 프로세스 종료 코드 0, 돌던 프로세스와 다음 실행 모두 <code>[1] 준비</code>, <code>[2] 백업 만들기</code>, <code>[3] 원본 지우기</code>.</p>
<ol>
<li><strong>실제 사고 기록.</strong> 2026-09-25 다른 세션이 같은 스크립트를 여러 번 제자리 편집(로그에 문법 오류 없음, 이유는 미확인), 2026-09-26 AI 세션 하나가 실행 중인 스크립트를 덮어씀(inode 복구로 피해를 막음). 셀프테스트가 통과해도 실데이터에서 틀렸던 비슷한 결의 기록은 <a href="https://blog.wonizz.com/2026/09/27/vibe-coding-reality-selftest-real-data/">바이브 코딩 현실, 테스트는 통과했는데 261편 중 6편만 맞았다</a>에 있습니다.</li>
</ol>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2026/10/06/claude-code-script-safe-edit/">[AI 코딩] 클로드 코드 되돌리기, 종료 코드 0인데 백업이 빠졌다</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2026/10/06/claude-code-script-safe-edit/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4102</post-id>	</item>
	</channel>
</rss>
