From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: display path of directory of a file and bug? Date: Sun, 6 Sep 2020 16:03:17 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34734"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.10.0 To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Sep 06 16:03:34 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEvGX-0008v4-OM for guile-user@m.gmane-mx.org; Sun, 06 Sep 2020 16:03:33 +0200 Original-Received: from localhost ([::1]:56344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEvGW-0000n7-O5 for guile-user@m.gmane-mx.org; Sun, 06 Sep 2020 10:03:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEvGN-0000mo-IR for guile-user@gnu.org; Sun, 06 Sep 2020 10:03:23 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:54955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEvGK-0006cK-MF for guile-user@gnu.org; Sun, 06 Sep 2020 10:03:23 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 40E6A2400FC for ; Sun, 6 Sep 2020 16:03:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1599400998; bh=zyaSMXZxvTdMgWjcSHxA3p+gGX0UGkAYA6Yc8nvHXOw=; h=To:From:Subject:Date:From; b=DolPrcWX0/wVlEFz8TX2a+JmmThX+PDz8DS71Ds+xazxDfHK9ApIeNDBXfJphsxnX zyJUa2jk7qwy+Lpc3BObUPUD1Wzu4Mh5RZMZ5xg10Jxoem8Q+bvGvaPSEvPjFdF+6X KL94p6BBE5x99tttn6kvRm73/FSWhZ4a4fm5q1iezKPedhS/2zBb9Ty0XDcjENza0D UuVsjcxhMZgNEPtJXDVCJZX7pAOWeeo/qNigrERBisKGGJ1PYPIP2M/aUFQ/0fz3Ac rZnGAcX2pt3NK1ORJmwzxHn/1STfXNUVMJhdKCxlsnUfGAIPjfKF2MWY2D20pqzJNL zma1nGn36nyjw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4BktRT599Rz6tmF for ; Sun, 6 Sep 2020 16:03:17 +0200 (CEST) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/06 07:09:38 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16869 Archived-At: 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 #) In ice-9/boot-9.scm: 718:2 5 (call-with-prompt ("prompt") # …) In ice-9/eval.scm: 619:8 4 (_ #(#(#))) In ice-9/boot-9.scm: 2806:4 3 (save-module-excursion #) 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