Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/usr/bin/env lua51 -- quickdiff.lua -- By Eduardo Ochs, 2007apr13 -- Compare the files in two directories -- (by default /tmp/page/angg/ and /tmp/page/rumi/) -- and print a report like this (with many many lines): -- -- changed: e/x.e -- same: .bashrc -- -- The first words are always "changed", "same", "deleted" or -- "created". The idea is that the output of this will be filtered -- with grep and awk and then blah blah etc. -- Typical usage: --[[ * (eepitch-shell) mkdir /tmp/page/ cd /tmp/page/ wget -O edrx-angg.tgz http://angg.twu.net/edrx.tgz mkdir /tmp/page/angg/ tar -C /tmp/page/angg/ -xvzf /tmp/page/edrx-angg.tgz * (eepitch-shell) makeLedrxtgz cp -v ~/TH/L/edrx.tgz /tmp/page/edrx-rumi.tgz mkdir /tmp/page/rumi/ tar -C /tmp/page/rumi/ -xvzf /tmp/page/edrx-rumi.tgz --]] -- Then: -- (find-sh "quickdiff.lua | sort | tee /tmp/page/odiff") -- (find-fline "/tmp/page/odiff") -- (find-sh "cd /tmp/page/angg/ && find -type f | cut -b 3-") -- (find-sh "cd /tmp/page/rumi/ && find -type f | cut -b 3-") angg = (arg and arg[1]) or "/tmp/page/angg/" rumi = (arg and arg[2]) or "/tmp/page/rumi/" anggfiles = split(getoutput("cd "..angg.." && find -type f | cut -b 3-")) rumifiles = split(getoutput("cd "..rumi.." && find -type f | cut -b 3-")) allfiles = {} anggcontents = {} rumicontents = {} for _,fname in ipairs(anggfiles) do allfiles[fname] = fname anggcontents[fname] = readfile(angg..fname) end for _,fname in ipairs(rumifiles) do allfiles[fname] = fname rumicontents[fname] = readfile(rumi..fname) end for fname,fnameagain in pairs(allfiles) do if anggcontents[fname] and rumicontents[fname] then if anggcontents[fname] == rumicontents[fname] then allfiles[fname] = "same" else allfiles[fname] = "changed" end else if anggcontents[fname] then allfiles[fname] = "deleted" end if rumicontents[fname] then allfiles[fname] = "created" end end print(allfiles[fname]..": "..fname) end -- (find-fline "/tmp/page/odiff")