guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

display path of directory of a file and bug?


From: Zelphir Kaltstahl
Subject: display path of directory of a file and bug?
Date: Sun, 6 Sep 2020 16:03:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.10.0

Hello Guile Users!

I've hit a weird issue when trying to display the path to the directory
of a source code file. The following experimental code I put into a file:

~~~~START: example.scm~~~~
(display
 (simple-format
  #f "~a\n"
  (dirname (current-filename))))
~~~~END~~~~~~~~~~~~~~~~~~~

Then I wanted to try, whether the output changes, depending on from
which directory I call:

~~~~START~~~~
guile example.scm
~~~~END~~~~~~

from

/home/user/dev/Guile/examples-and-convenience-procedures/file-system

The output was:

~~~~START~~~~
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
~~~~END~~~~~~

As I expected. Then I tried from one directory up:

~~~~START~~~~
guile file-system/example.scm
~~~~END~~~~~~

And the output stayed the same. Satisfied, that the output stays the
same, I renamed the file into something more meaningful. (btw.: If there
is a better way to get the path of the directory of a file, please let
me know!) Then something weird happened:

~~~~START~~~~

user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ mv 
example.scm display-dir-of-file.scm
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
display-dir-of-file.scm 
Backtrace:
In ice-9/boot-9.scm:
  1736:10  7 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In unknown file:
           6 (apply-smob/0 #<thunk 7f82ac5434c0>)
In ice-9/boot-9.scm:
    718:2  5 (call-with-prompt ("prompt") #<procedure 7f82ac5568e0 at ice…> …)
In ice-9/eval.scm:
    619:8  4 (_ #(#(#<directory (guile-user) 7f82ac17ef00>)))
In ice-9/boot-9.scm:
   2806:4  3 (save-module-excursion #<procedure 7f82ac1711b0 at ice-9/boot…>)
  4351:12  2 (_)
In display-dir-of-file.scm:
      4:2  1 (_)
In unknown file:
           0 (dirname #f)

ERROR: In procedure dirname:
In procedure scm_to_utf8_stringn: Wrong type argument in position 1 (expecting 
string): #f
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ mv 
display-dir-of-file.scm example.scm
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
example.scm 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ cp 
example.scm display-dir-of-file.scm
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
example.scm 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
display-dir-of-file.scm 
;;; note: source file 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system/display-dir-of-file.scm
;;;       newer than compiled 
/home/user/.cache/guile/ccache/3.0-LE-8-4.3/home/user/dev/Guile/examples-and-convenience-procedures/file-system/display-dir-of-file.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system/display-dir-of-file.scm
;;; compiled 
/home/user/.cache/guile/ccache/3.0-LE-8-4.3/home/user/dev/Guile/examples-and-convenience-procedures/file-system/display-dir-of-file.scm.go
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
display-dir-of-file.scm 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$ guile 
display-dir-of-file.scm 
/home/user/dev/Guile/examples-and-convenience-procedures/file-system
user@xlx200:~/dev/Guile/examples-and-convenience-procedures/file-system$

~~~~END~~~~~~

I also tried with `guile -L . ...` and `guile -L file-system ...` at
some point, but now it simply works and I cannot reproduce the error any
longer. It seems to have something to do with the file name itself. I
also don't see, why it would compile again after copying the file. So I
tested something:

If I move a file using `mv`, a recomplation seems to be not required. If
I copy the file instead, Guile recompiled it. Does this have something
to do with inodes or creation date, which is differently handled when
using `cp` instead of `mv`?

With the whole error thing, I am beginning to doubt myself, but I am
quite sure (99%), that I did not change the code in the file during the
whole process.

This was inside Emacs M-x shell. My GNU Guile is installed via GNU Guix
and is version 3.0.4.

Since it now seems to work, I am only concerned, that there might be a
bug somewhere. Or is there an explanation?

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]