[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Does ABCL support the "~" home directory?

Mirko

4/14/2016 7:44:00 PM

I am trying out ABCL on Windows 7 (in order to process Excel files).

It does not seem to understand paths such as "~/asdf".

I could not find anything in the documentation.

I'd like to double-check before I start modifying some existing code.

Thanks,

Mirko
3 Answers

Dimitri Fontaine

4/14/2016 8:05:00 PM

0

Mirko Vukovic <mirko.vukovic@gmail.com> writes:
> It does not seem to understand paths such as "~/asdf".

I have no idea. Here's what I use when I need to do that:

(defun expand-user-homedir-pathname (namestring)
"Expand NAMESTRING replacing leading ~ with (user-homedir-pathname)"
(typecase namestring
(pathname namestring)
(string
(cond ((or (string= "~" namestring) (string= "~/" namestring))
(user-homedir-pathname))

((and (<= 2 (length namestring))
(char= #\~ (aref namestring 0))
(char= #\/ (aref namestring 1)))
(uiop:merge-pathnames*
(uiop:parse-unix-namestring (subseq namestring 2))
(user-homedir-pathname)))

(t
(uiop:parse-unix-namestring namestring))))))

Regards,
--
dim

Kaz Kylheku

4/14/2016 8:09:00 PM

0

On 2016-04-14, Mirko Vukovic <mirko.vukovic@gmail.com> wrote:
> I am trying out ABCL on Windows 7 (in order to process Excel files).
>
> It does not seem to understand paths such as "~/asdf".

You're on Windows! Can you type "~/asdf" into Windows Explorer?

Tilde expansion is a feature of the POSIX shell language and related
dialects. The kernels of Unix-like systems do not understand it,
either.

It's not a Lisp convention, either. The fact that we can do this in,
say, CLISP:

[1]> (open "~/foo")

*** - OPEN: File #P"/home/kaz/foo" does not exist

is completely gratuitous; CLISP has chosen to provide shell-like
tilde expansion, even though it isn't the shell language.

This is implemented in the logic which parses a path namestring to
a pathname object. It is not a feature of open itself nor of the
semantics of pathname objects themselves:

[1]> (open (make-pathname :name "~"))

*** - OPEN: File #P"/home/kaz/txr/~" does not exist

[2]> (open (make-pathname :directory "~" :name "foo"))

*** - OPEN: Directory #P"/~/" does not exist

I don't see a way of escaping the tilde when creating a pathname via
namestring parsing. This is in contrast to the shell language, in which
we can backslash the tilde to remove its special meaning:

$ ls -ld ~
drwxr-xr-x 73 kaz kaz 4096 Apr 14 13:00 /home/kaz
$ ls -ld \~
ls: cannot access ~: No such file or directory

> I could not find anything in the documentation.

Why would the documentation write about things which are not
requirements? The set of such features is indefinitely large.
Can you imagine?

"ABCL doesn't implement POSIX shell tilde expansion, Fortran common
blocks, COBOL structure assignment by field name, C pointers, SQL
stored procedures, Intercal COMEFROM, ..."

Mirko

4/14/2016 8:47:00 PM

0

On Thursday, April 14, 2016 at 4:09:00 PM UTC-4, Kaz Kylheku wrote:
> On 2016-04-14, Mirko Vukovic <mirko.vukovic@gmail.com> wrote:
> > I am trying out ABCL on Windows 7 (in order to process Excel files).
> >
> > It does not seem to understand paths such as "~/asdf".
>
> You're on Windows! Can you type "~/asdf" into Windows Explorer?
>
> Tilde expansion is a feature of the POSIX shell language and related
> dialects. The kernels of Unix-like systems do not understand it,
> either.
>
> It's not a Lisp convention, either. The fact that we can do this in,
> say, CLISP:
>
> [1]> (open "~/foo")
>
> *** - OPEN: File #P"/home/kaz/foo" does not exist
>
> is completely gratuitous; CLISP has chosen to provide shell-like
> tilde expansion, even though it isn't the shell language.
>
> This is implemented in the logic which parses a path namestring to
> a pathname object. It is not a feature of open itself nor of the
> semantics of pathname objects themselves:
>
> [1]> (open (make-pathname :name "~"))
>
> *** - OPEN: File #P"/home/kaz/txr/~" does not exist
>
> [2]> (open (make-pathname :directory "~" :name "foo"))
>
> *** - OPEN: Directory #P"/~/" does not exist
>
> I don't see a way of escaping the tilde when creating a pathname via
> namestring parsing. This is in contrast to the shell language, in which
> we can backslash the tilde to remove its special meaning:
>
> $ ls -ld ~
> drwxr-xr-x 73 kaz kaz 4096 Apr 14 13:00 /home/kaz
> $ ls -ld \~
> ls: cannot access ~: No such file or directory
>
> > I could not find anything in the documentation.
>
> Why would the documentation write about things which are not
> requirements? The set of such features is indefinitely large.
> Can you imagine?
>
> "ABCL doesn't implement POSIX shell tilde expansion, Fortran common
> blocks, COBOL structure assignment by field name, C pointers, SQL
> stored procedures, Intercal COMEFROM, ..."

Thanks for the clarification. I was spoiled by CCL. It does understand "~".

Thanks (to you and Dimitri).

Mirko