Subject: Re: [SWIPL] absolute_file_name/2

From: Jan Wielemaker <[email-masked]>
Date: Wed, 11 Apr 2001 10:39:19 +0200

On Tue, 10 Apr 2001, Nicos Angelopoulos wrote:
>Hello, 
>
>i am using SWI on linux, (2 different machines 2 different pl versiona, 
>                          one is 4.0.2)
>
>when i do (e.g. on 4.0.2)
>
>?- absolute_file_name('~', A ).
>
>i get 
>
>A = '/usr/nicos/pl/~' ;
>
>(where /usr/nicos/pl is my pwd at typing % pl) 
>
>
>is there something wrong with my installations, 
>or i am just misreading the manual ?
>or is it Linux specific problem ?
>
>does anybody get anything more sensible on a different OS ?

I was almost trapped too, but the answer is correct. 
absolute_file_name/2 doesn't treat any character except for / (and \ and
the start sequence drive: on windows) special.  Hence it expands to the
absolute-path for a file named ~ in the current directory.

What you are looking for is expand_file_name(+Spec, -ListOfExpansions)
that handles ~, $var, *, ? and {...}, expanding to a list of matching
files.

This has been changed (see ChangeLog) rather long ago as especially on
windows names tend to have ~ and $ all over the place, leading to weird
results and errors.

	--- Jan