* Absolute path of source file
[not found] <877cb21j0d.fsf@housseini.me>
@ 2024-09-23 15:35 ` reza
2024-09-23 15:39 ` Retropikzel
0 siblings, 1 reply; 4+ messages in thread
From: reza @ 2024-09-23 15:35 UTC (permalink / raw)
To: guile-user@gnu.org
Hi List
How can I get the absolute path to a source file from itself. In bash
this would look like something along the lines
realpath $(dirname $0)
but I could not figure out how to achieve this in guile.
Thanks for any hints!
Cheers,
Reza
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Absolute path of source file
2024-09-23 15:35 ` Absolute path of source file reza
@ 2024-09-23 15:39 ` Retropikzel
[not found] ` <871q1a1ig0.fsf@housseini.me>
0 siblings, 1 reply; 4+ messages in thread
From: Retropikzel @ 2024-09-23 15:39 UTC (permalink / raw)
To: reza; +Cc: guile-user@gnu.org
On Mon, 23 Sep 2024 15:35:03 +0000
reza <reza@housseini.me> wrote:
> Hi List
>
> How can I get the absolute path to a source file from itself. In bash
> this would look like something along the lines
>
> realpath $(dirname $0)
>
> but I could not figure out how to achieve this in guile.
>
> Thanks for any hints!
> Cheers,
> Reza
>
Hi! Might example from here:
https://www.gnu.org/software/guile/manual/guile.html#Load-Paths-1
work?
(dirname (current-filename))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Absolute path of source file
[not found] ` <871q1a1ig0.fsf@housseini.me>
@ 2024-09-23 15:47 ` reza
2024-09-24 17:17 ` Zelphir Kaltstahl
0 siblings, 1 reply; 4+ messages in thread
From: reza @ 2024-09-23 15:47 UTC (permalink / raw)
To: retropikzel@iki.fi; +Cc: guile-user@gnu.org
Hi Retropikzel
Perfect, works out of the box!
I missed this part in the manual, just saw that it is in chapter "Source
Properties" where I would never have guessed to look at.
Thanks very much,
Reza
> On Mon, 23 Sep 2024 15:35:03 +0000
> reza <reza@housseini.me> wrote:
>
>> Hi List
>>
>> How can I get the absolute path to a source file from itself. In bash
>> this would look like something along the lines
>>
>> realpath $(dirname $0)
>>
>> but I could not figure out how to achieve this in guile.
>>
>> Thanks for any hints!
>> Cheers,
>> Reza
>>
>
> Hi! Might example from here:
> https://www.gnu.org/software/guile/manual/guile.html#Load-Paths-1
>
> work?
>
> (dirname (current-filename))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Absolute path of source file
2024-09-23 15:47 ` reza
@ 2024-09-24 17:17 ` Zelphir Kaltstahl
0 siblings, 0 replies; 4+ messages in thread
From: Zelphir Kaltstahl @ 2024-09-24 17:17 UTC (permalink / raw)
To: reza; +Cc: Guile User
Hello reza!
On 23.09.24 17:47, reza wrote:
> Hi Retropikzel
>
> Perfect, works out of the box!
> I missed this part in the manual, just saw that it is in chapter "Source
> Properties" where I would never have guessed to look at.
> Thanks very much,
> Reza
>
>> On Mon, 23 Sep 2024 15:35:03 +0000
>> reza<reza@housseini.me> wrote:
>>
>>> Hi List
>>>
>>> How can I get the absolute path to a source file from itself. In bash
>>> this would look like something along the lines
>>>
>>> realpath $(dirname $0)
>>>
>>> but I could not figure out how to achieve this in guile.
>>>
>>> Thanks for any hints!
>>> Cheers,
>>> Reza
>>>
>> Hi! Might example from here:
>> https://www.gnu.org/software/guile/manual/guile.html#Load-Paths-1
>>
>> work?
>>
>> (dirname (current-filename))
I just want to add, that in most cases you can probably make things work using
the `guile -L` argument and naming the files of guile modules according to the
module defined in them. It has been a long time, since I had to reach for
something like `(dirname (current-filename))`. Of course there might be cases,
where you want to have that directory as a string in your code or so. I am only
writing this, because it is often brought up in a context of adding things to
the load path, where it should not be necessary.
For example see:
https://codeberg.org/ZelphirKaltstahl/guile-algorithms/src/commit/97f29e9a9414bd068e9b6e0745a768ad64a10dac/readme.md.
And if that is too much of a hassle, you could create a makefile, that runs
either the program or a guile shell that has the directories added to the load
path. Something like
https://codeberg.org/ZelphirKaltstahl/guile-algorithms/src/commit/97f29e9a9414bd068e9b6e0745a768ad64a10dac/graphs/Makefile.
Best regards, Zelphir
--
repositories:https://notabug.org/ZelphirKaltstahl,https://codeberg.org/ZelphirKaltstahl
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-24 17:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <877cb21j0d.fsf@housseini.me>
2024-09-23 15:35 ` Absolute path of source file reza
2024-09-23 15:39 ` Retropikzel
[not found] ` <871q1a1ig0.fsf@housseini.me>
2024-09-23 15:47 ` reza
2024-09-24 17:17 ` Zelphir Kaltstahl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).