How to use diff3
together with ed
? My attempt below does not match diff3 --merge
output, so I must be doing something wrong.
Context: I've ported OpenBSD's diff3prog.c utility to be used in BusyBox, which has diff
and ed
.
cat <<- EOF > parent.txt
1
2
3
EOF
cat <<- EOF > ours.txt
1
2
3
EOF
cat <<- EOF > theirs.txt
1
2
3
4
EOF
f1=ours.txt
f2=parent.txt
f3=theirs.txt
diff3 --merge $f1 $f2 $f3 > merged_good.txt
diff3 -E $f1 $f2 $f3 | ed $f1
#prints:
#6
#?
mv $f1 merged_bad.txt
cat merged_good.txt
#prints:
#1
#2
#3
#4
cat merged_bad.txt
#prints:
#1
#2
#3
(originally I posted this in the comment above. no-one added any further context, but the problem is solved, so I'm adding it as the answer as well)
It seems that
diff3
output missesw
ed
command. So to get expected output, one should(diff3 -E $f1 $f2 $f3; echo w) | ed $f1
.