GNU bug report logs - #34860
Probing broken symlinks always involves errors

Previous Next

Package: guile;

Reported by: Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>

Date: Thu, 14 Mar 2019 19:56:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34860 in the body.
You can then email your comments to 34860 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#34860; Package guile. (Thu, 14 Mar 2019 19:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Thu, 14 Mar 2019 19:56:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>
To: bug-guile <at> gnu.org
Subject: Probing broken symlinks always involves errors
Date: Thu, 14 Mar 2019 20:50:57 +0100
Hi,
I wrote a little application that tries to probe whether a symlink
exists. The `stat` function has an undocumented optional parameter that
lets stat return #f when the file does not exist. With this argument one
can probe for any files excluding broken symlinks.
lstat does not offer this argument. Therefore I needed to use
guard-expressions around lstat to probe for broken symlinks.

So probing broken symlinks relies on errors in the control flow and is
not straight forward. Maybe we should add the optional argument that
`stat` has and document the arguments for both commands.

I am using guile 2.2.4.

Tim.




Information forwarded to bug-guile <at> gnu.org:
bug#34860; Package guile. (Wed, 10 Apr 2019 19:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 34860 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>
Cc: 34860 <at> debbugs.gnu.org
Subject: Re: bug#34860: Probing broken symlinks always involves errors
Date: Wed, 10 Apr 2019 15:22:49 -0400
Hi Tim,

Tim Gesthuizen <tim.gesthuizen <at> yahoo.de> writes:

> I wrote a little application that tries to probe whether a symlink
> exists. The `stat` function has an undocumented optional parameter that
> lets stat return #f when the file does not exist. With this argument one
> can probe for any files excluding broken symlinks.
> lstat does not offer this argument. Therefore I needed to use
> guard-expressions around lstat to probe for broken symlinks.
>
> So probing broken symlinks relies on errors in the control flow and is
> not straight forward.

I would suggest using 'false-if-exception', which is documented in the
manual:

  (false-if-exception (lstat file-name))

That seems fairly straightforward and readable, no?

I'm not sure that errors in the control flow is necessarily something
that we need to avoid in cases like this.  It's true that there's some
minor expense involved in handling the exception, but I suspect it's
lost in the noise compared with the expense of the 'lstat' system call
itself.

Do you see a practical problem with this approach?

> Maybe we should add the optional argument that `stat` has and document
> the arguments for both commands.

I'm not strongly opposed to the idea, but it raises the question of what
to do with the corresponding C API function 'scm_lstat'.  We certainly
can't change the number of arguments to 'scm_lstat' in the 2.2.x series,
because that would break ABI compatibility.  We could change it in the
next release series, but that would require source-level changes in any
code that uses 'scm_lstat'.

Alternatively, we could keep 'scm_lstat' unchanged, and add a new
internal C function with the optional argument, bound to Scheme 'lstat'.

Anyway, I'm inclined to simply suggest using 'false-if-exception'.

What do you think?

Regardless, thanks for bringing my attention to the fact that 'scm_stat'
is incorrectly documented in the manual.  It asserts that there's only
one argument to that function, but in fact there are now two.  That's
definitely a bug.

     Regards,
       Mark




Information forwarded to bug-guile <at> gnu.org:
bug#34860; Package guile. (Thu, 11 Apr 2019 18:06:02 GMT) Full text and rfc822 format available.

Message #11 received at 34860 <at> debbugs.gnu.org (full text, mbox):

From: Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 34860 <at> debbugs.gnu.org
Subject: Re: bug#34860: Probing broken symlinks always involves errors
Date: Thu, 11 Apr 2019 20:05:09 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Mark,

Mark H Weaver writes:
> Anyway, I'm inclined to simply suggest using 'false-if-exception'.
>
> What do you think?

I'm fine with this solution. My point was more about lowering the entry
barrier for beginners than performance.
If the change breaks ABI it is probably just not worth it.

- From my point of view we can close the ticket unless you want to keep it
open until the documentation for stat is fixed.

Tim.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEKUiC5+8BRKEri5fa0uWPaa77GdUFAlyvgdUACgkQ0uWPaa77
GdWvVQf/QdJ6Mze6jdx3qeFNjcq0hJCdkjykjWQal2m2eFNan+9RgrWUo/oGmJxq
9kVrckRE8lSH0Lh0jy5vhVtf4kBLcEKMB3oHBg7SM/w10nYsqkeZx+hV+MQkKQ3O
FomSddVDwa1R2aCHOJ55anHehvY5ICe2iQnASRPV4S/1h29b4cqg6W8OoKAiB2XR
GP7xfJ2s9y1IUm/0zSaAwpzr+CXcsplZVDgKcERo46/lfovFVsynhFJqNuU6ulBF
QJZAZyohH4SYiPQ21zq4r95WAr1UUfm8awJJuv5zgWx7wTcipUomXyINdnV6jEdT
bUGnNNOqpmhzzYuP0j+lI3yRqYb2/g==
=JSqx
-----END PGP SIGNATURE-----




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sun, 30 Jun 2019 19:55:02 GMT) Full text and rfc822 format available.

Notification sent to Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>:
bug acknowledged by developer. (Sun, 30 Jun 2019 19:55:02 GMT) Full text and rfc822 format available.

Message #16 received at 34860-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>
Cc: Mark H Weaver <mhw <at> netris.org>, 34860-done <at> debbugs.gnu.org
Subject: Re: bug#34860: Probing broken symlinks always involves errors
Date: Sun, 30 Jun 2019 21:54:04 +0200
Hi Tim,

Tim Gesthuizen <tim.gesthuizen <at> yahoo.de> skribis:

> Mark H Weaver writes:
>> Anyway, I'm inclined to simply suggest using 'false-if-exception'.
>>
>> What do you think?
>
> I'm fine with this solution. My point was more about lowering the entry
> barrier for beginners than performance.
> If the change breaks ABI it is probably just not worth it.
>
> From my point of view we can close the ticket unless you want to keep it
> open until the documentation for stat is fixed.

Commit 63f54a7bc6adbc0f1b397872fb7eb96e84967ff1 updates the manual to
document the optional parameter of ‘stat’.

I think we can close the bug now.  :-)

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Jul 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.