I do the most basic thing in every script
SCRIPT=`readlink -f ${0}`
HOME=`dirname $SCRIPT`
and, given $0 = C:\Users\dir\file, readlink gives me /cygdrive/c/CURRENT_DIRECTORY/C:\Users\dir\file so that the next dirname produces terrible /cygdrive/c/Users/CURRENT_DIRECTORY/C:\Users\dir instead of C:\Users\dir or /cygdrive/c/Users/dir
Is it supposed to work this way?
It seems that I have found the answer: we should convert
$0into cygwin format thenreadlinkcan work with it