GNU bug report logs - #44186
Recursive mkdir

Previous Next

Package: guile;

Reported by: divoplade <d <at> divoplade.fr>

Date: Fri, 23 Oct 2020 22:01:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Ricardo Wurmus <rekado <at> elephly.net>
To: Bengt Richter <bokr <at> bokr.com>
Cc: 44186 <at> debbugs.gnu.org, d <at> divoplade.fr, zimon.toutoune <at> gmail.com
Subject: bug#44186: Recursive mkdir
Date: Sun, 25 Oct 2020 08:45:21 +0100
Bengt Richter <bokr <at> bokr.com> writes:

> Hi divoplade,
>
> On +2020-10-24 08:17:47 +0200, divoplade wrote:
>> Hello,
>> 
>> Le samedi 24 octobre 2020 à 01:32 +0200, Bengt Richter a écrit :
>> > An alternate solution could be programmed using ffi, as documented in
>> > [1], n'est-ce pas?
>> To be clear, you would rather have that function as guile code rather
>> than extending the C function? I'm OK with that, but in which file
>> should I put that function? My instinct was to put the code near the
>> mkdir function, and that happened to be in a C file, so I went C.

We should all be writing fewer lines of C code and more Scheme :)

> Seems logical, and probably where I'd go, but please be careful!
> Don't make a C version of this hack:
> ┌───────────────────────────────────────────────────────────────────────────────┐
> │ (define (my-mkdir-p path . ignore) (system (string-append "mkdir -p " path))) │
> └───────────────────────────────────────────────────────────────────────────────┘
> You can then write (my-mkdir-p "foo-dir/bar-dir") and it'll do the job.
>
> But it's definitely safer to skip the hack and write
> ┌─────────────────────────────────────┐
> │ (system "mkdir -p foo-dir/bar-dir") │
> └─────────────────────────────────────┘
> and not give anything a chance to inject something bad via unsanitized
> parameters.

Use “system*” instead of “system” when you need to work with
user-provided values.  For mkdir-p, however, using any variant of
“system” is inelegant.

-- 
Ricardo

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

Previous Next


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