I am writing a diff parser for thunar but it is driving me mad.
The full idea is in it is simplest to select two files right click on them and select the option compare, then the result of diff between the two files is parsed to xmessage. The simplest works nicely, but I also want to compare files from different locations, so the idea is to copy one or two files and then run diff over them.
The great trouble is that I am not being able to format the output of xclip in order that diff could understand them (it reads the two lines as one filename)
What I tried:
selected="$(xclip -selection clipboard -o)"
diff -qyr "\"${selected//$'\n'/\" \"}\""
n=0
echo "$selected"| while read selection; do
compare="$compare ${selection// /\ }"
diff -qyr ${compare}
n=$(($n+1))
done
echo "${compare[*]}"
echo xmessage diff: $(diff -qyr "${compare[0]}" "${compare[1]}")
I solved this before hitting post using tail and head:
file1="$(echo "$selected"|head -n1)"
file2="$(echo "$selected"|tail -n1)"
xmessage "$(diff -qyr "$file1" "$file2")"
It was simpler than I thought, though why the more complicated solutions did not work?