From 81b713e5091c45333e9610b2a9885d963d32dd67 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 26 Apr 2006 15:28:28 +0000 Subject: [PATCH] use ls+sed in place of readlink on Mac OS X or when readlink isn't present svn: r2803 --- collects/launcher/launcher-unit.ss | 43 +++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/collects/launcher/launcher-unit.ss b/collects/launcher/launcher-unit.ss index 57e7b853e9..6caf4dc553 100644 --- a/collects/launcher/launcher-unit.ss +++ b/collects/launcher/launcher-unit.ss @@ -238,21 +238,36 @@ (regexp-replace* #rx"\"" s "\\\\\"")) (define (make-relative-path-header dest bindir) - (let ([dirname (find-executable-path "dirname")] - [basename (find-executable-path "basename")] - [readlink (find-executable-path "readlink")] - [dest-explode (explode-path (normalize-path dest))] - [bindir-explode (explode-path (normalize-path bindir))] - [newline "\n"]) - (if (and dirname basename readlink + (let* ([dirname (find-executable-path "dirname")] + [basename (find-executable-path "basename")] + [readlink (and (not (eq? 'macosx (system-type))) + (find-executable-path "readlink"))] + [ls (and (not readlink) + (find-executable-path "ls"))] + [sed (and (not readlink) + (find-executable-path "sed"))] + [dest-explode (explode-path (normalize-path dest))] + [bindir-explode (explode-path (normalize-path bindir))] + [newline "\n"]) + (if (and dirname basename (or readlink (and ls sed)) (equal? (car dest-explode) (car bindir-explode))) (format (string-append "# Programs we need (avoid depending on user's PATH):" newline "dirname=\"~a\"" newline "basename=\"~a\"" newline - "readlink=\"~a\"" newline + (if readlink + "readlink=\"~a\"" + "~a") newline + newline + (if readlink + "" + (string-append + "readlink() {" newline + " P=`\"$ls\" -l \"$1\" | \"$sed\" -e 's/^.* -> //'`" newline + "}" newline + newline)) "# Remember current directory" newline "saveD=`pwd`" newline newline @@ -263,7 +278,10 @@ "F=`$basename \"$0\"`" newline "cd \"$D\"" newline "while [ -L \"$F\" ]; do" newline - " P=`$readlink \"$F\"`" newline + (if readlink + " P=`$readlink \"$F\"`" + " readlink \"$F\"") + newline " D=`$dirname \"$P\"`" newline " F=`$basename \"$P\"`" newline " cd \"$D\"" newline @@ -277,7 +295,12 @@ newline) (protect-shell-string (path->string dirname)) (protect-shell-string (path->string basename)) - (protect-shell-string (path->string readlink)) + (if readlink + (protect-shell-string (path->string readlink)) + (format + "ls=\"~a\"\nsed=\"~a\"" + (protect-shell-string (path->string ls)) + (protect-shell-string (path->string sed)))) (protect-shell-string (path->string (apply build-path