Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-Id: <200010272122.e9RLMnP11586@stay.intouchsys.com> To: cygwin AT sourceware DOT cygnus DOT com Subject: sh-utils: need interface to realpath() Date: Fri, 27 Oct 2000 17:22:48 EDT From: Stephen Gildea I find I need a simple utility in a shell script: something to read through symlinks and give me the true name of a file. I don't see anything in Bash (2.04), sh-utils (2.0), or Cygwin (1.0) that provides this functionality. There is a common Unix function realpath() that does what I want, but it needs to be wrapped in a small utility program. I'm not sure where to suggest this utility be added. We needed it in Cygwin to clean Cygwin pathnames of symlinks before passing them to native NT programs, so I'm offering this here. It is also possible the base GNU shell utilities would be a good place to add such a program. I'm appending one possible, simple implementation by my co-worker Marc Neuberger. It also handles interpreting the Cygwin root-- something else we need to expand before we can pass a pathname to a native NT process. < Stephen #include #include #include #include int main(int argc, char *argv[]) { char real[512]; char win32[512]; int i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } realpath(argv[1], real); cygwin_conv_to_full_win32_path(real, win32); for (i= 0; win32[i]; i++) { if (win32[i] == '\\') { win32[i]= '/'; } } printf("%s\n", win32); } -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com