unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Bengt Richter <bokr@bokr.com>
Cc: 44186@debbugs.gnu.org, d@divoplade.fr, zimon.toutoune@gmail.com
Subject: bug#44186: Recursive mkdir
Date: Sun, 25 Oct 2020 08:45:21 +0100	[thread overview]
Message-ID: <87h7qi3g1a.fsf@elephly.net> (raw)
In-Reply-To: <20201025041350.GA14747@LionPure>


Bengt Richter <bokr@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

  reply	other threads:[~2020-10-25  7:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6ff632f5c1e378647cecc7177b7018fb8a0ee6d4.camel@divoplade.fr>
     [not found] ` <86sga420pw.fsf@gmail.com>
2020-10-23 22:00   ` bug#44186: Recursive mkdir divoplade
2020-10-23 22:07     ` zimoun
2020-10-23 23:32       ` Bengt Richter
2020-10-24  6:17         ` divoplade
2020-10-25  4:13           ` Bengt Richter
2020-10-25  7:45             ` Ricardo Wurmus [this message]
2020-10-25  9:07               ` divoplade
2020-10-25 10:44                 ` divoplade
     [not found]     ` <handler.44186.B.16034904223692.ack@debbugs.gnu.org>
2020-10-23 22:46       ` divoplade
2020-10-26 21:05     ` Leo Prikler
2020-10-27  7:01       ` divoplade
2020-10-27  9:19         ` Leo Prikler
2020-10-27 10:21           ` divoplade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7qi3g1a.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=44186@debbugs.gnu.org \
    --cc=bokr@bokr.com \
    --cc=d@divoplade.fr \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).