#!/bin/bash # # Category: Totally Free Stuff # Author: Hannu E K Nevalainen, Mariefred, Sweden in September 2003 # # Verify the output of cygwin 'find' # # Date Version Comment # 2003-09-12 1.0 Made it be slightly more general than prior versions # 2003-09-13 1.1 $fn could end up with spaces in it, sed fixes that. if [ -z "$1" ] ;then echo -e " use $0 DIRECTORY This will launch 'cmd /c dir.exe' -and- '/bin/find.exe' on DIRECTORY, performing the necesary conversion and then launching /bin/diff.exe on it. It creates a bunch of files in the current directory; names as in: FIND_TEST_.. is: (s)dir - (sorted) cmd /c dir.exe output find - output of find w - find output, with MS-style paths sw - .w contents sorted diff - output of 'diff -iup' on sdir and sw files NOTE: sw and sdir files will ALWAYS have LF line endings." exit 1 fi TESTP="`cygpath -wl \"$1\"`" TESTPCYG="`cygpath -u ${TESTP}`" P="`echo ${TESTPCYG} | sed -e 's./.-.g'`" VOL="`cmd /c dir ${TESTP} | ( read Vol Vol Vol Vol Vol Vol ; echo $Vol )`" SER="`cmd /c dir ${TESTP} | ( read Ser ; read Ser Ser Ser Ser Ser; echo $Ser )`" echo " About to check if 'C:DIR.EXE /AD' and '/BIN/FIND.EXE -TYPE D' outputs match for ${TESTP} and ${TESTPCYG} -------------------------------------------------------------" echo " *** Generating cygcheck output" cygcheck -svr >c_svr-snap.txt echo " *** grep -i CYGWIN1 from cygcheck output" grep -i cygwin1 c_svr-snap.txt D=`grep -i ".bin.cygwin1.dll" c_svr-snap.txt | ( read size D scratch ; echo $D) | sed -e 's./.-.g'` fn="`echo FIND_CHK.${P}-${VOL}-${SER}.${D} | sed -e 's. ._.g'`" echo " *** Generating DIR output" cmd /c dir /ad /s /b "${TESTP}" >${fn}.dir sort ${fn}.dir >${fn}.sdir echo " *** Generating find output" find "${TESTPCYG}" -type d >${fn}.find echo " *** Converting find output to MS-style paths" cat ${fn}.find | ( read line; while [ ! -z "$line" ]; \ do cygpath -w "$line"; read line; done) >${fn}.w sort ${fn}.w >${fn}.sw echo " *** Generating diff output" d2u ${fn}.sdir ${fn}.sw >/dev/null 2>&1 diff -iup ${fn}.sw ${fn}.sdir >${fn}.diff if [ `wc -l <${fn}.diff` -gt 30 ] ; then head -20 ${fn}.diff echo " <*** SNIP ***> " tail ${fn}.diff echo " *** `wc -l <${fn}.diff` lines in ${fn}.diff" else cat ${fn}.diff fi echo " *** Counting lines" wc -l ${fn}.sdir ${fn}.sw echo " *** Remove FILES created of this run with: rm ${fn}.* *** See full diff with: less ${fn}.diff *** Compare dir/find output with: diff -y ${fn}.sw ${fn}.sdir | less"