Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#77 resolve-file-name removes trailing /

closed-later
Olin Shivers
run-time (53)
5
2004-01-29
2004-01-27
No

resolve-file-name removes a trailing slash, if present, but this is not documented.

I think that it is the wrong behaviour anyway, i.e. that it shouldn't remove trailing slashes.

This, in turn, creates bugs in functions that use resolve-file-name but put some semantics in a trailing slash, like for example the library path stuff: A trailing slash in SCSH_LIB_DIRS gets ignored, instead of enabling recursive search. If you decide to keep the current resolve-file-name behaviour, please fix these places. You'll probably want to give users a function that does ~-expansion / relative-to-absolute conversion without removing trailing slashes, too.

--- scsh-0.6.5.orig/scsh/fname.scm
+++ scsh-0.6.5/scsh/fname.scm
@@ -169,8 +169,7 @@
fname)))

(define (resolve-file-name fname . maybe-root)
- (let* ((root (ensure-file-name-is-nondirectory (:optional maybe-root ".")))
- (fname (ensure-file-name-is-nondirectory fname)))
+ (let* ((root (:optional maybe-root ".")))
(if (zero? (string-length fname))
"/"
(let ((c (string-ref fname 0)))

Discussion

  • Logged In: YES
    user_id=17553

    RESOLVE-FILE-NAME works on file names which do not have trailing
    slashes, see Section 5.1.1 of the manual. So I think the implementation is
    at least what Olin Shivers had in mind. However, I agree that the behaviour
    is not very intuitive and I ran into this problem by myself as you can see in
    the library search code. However, I fixed this a couple of weeks ago in
    CVS.

    --
    Martin

     
    • status: open --> closed-rejected
     
  • Logged In: YES
    user_id=41822

    > So I think the implementation is at least what Olin Shivers had in mind.

    I never doubted that :-)

    > RESOLVE-FILE-NAME works on file names which do not have trailing slashes, see Section 5.1.1 of the manual.

    The terminology is extremely confusing. My understanding of English is that "an A in B form" is still an A. And that when you say "An A", it can be in B form or in another form. Here, the other form has no name and is referred to as just "an A". But maybe it is just my udnerstanding of English that's warped.

    The text itself uses "file-name form" to disambiguate. It would be clearer if "a file-name form" would be defined to be what now "a file-name" is. And use "file-name" for "either file-name form or directory form" and "file-name form" for what is now "file-name".

    <hair splitting mode>

    The documentation says:

    * Do ~ expansion.

    This doesn't say that it outputs a file-name

    * If dir is given, convert a relative file-name to an absolute file-name, relative to directory dir.

    This says that, if given a relative file-name, it outputs an absolute file-name. It doesn't say what it does to a file-name in directory form...

     
  • Logged In: YES
    user_id=17553

    What I really don't understand is the following sentence in the manual from
    which I expected enlightenment:

    However, most procedures that expect a directory argument will coerce a
    file-name in directory form to file-name form if it does not have a trailing
    slash.

    Now, a trailing slash is exactly the token that characterizes a "file-name in
    directory form" so what's the proposition of the sentence above?

    I guess we really need to know what Olin had in mind before we can clarify
    the manual.

     
    • assigned_to: nobody --> olin-shivers
    • status: closed-rejected --> closed-later