What is the idiomatic way to append a string to a file?

1 view
Skip to first unread message

Vladimir Nikishkin

unread,
Feb 5, 2026, 9:28:44 AM (4 days ago) Feb 5
to chibi-scheme
It seems that r7rs is missing a standard append procedure (or maybe I
have not found it), and I also did not find a file-append function in
the (chibi ...) namespace.

What is the standard way to append something to a file?
At the moment I am using

(shell (echo ,string) (>> ,file))

which looks a bit ridiculous

is there a better way?

Also, is there a better way to send a variable to a posix command in
(chibi shell)?

I tried something like (shell (cat) (<<< "test")), but this does not work.


--
Yours sincerely, Vladimir Nikishkin
(Sent from GMail web interface.)

Alex Shinn

unread,
Feb 5, 2026, 8:21:52 PM (3 days ago) Feb 5
to chibi-...@googlegroups.com
(chibi log) defines but does not export:

(define (open-output-file/append path)
        (let ((fd (open path
                        (+ open/create open/write open/append open/non-block))))
          (open-output-file-descriptor fd)))

I should probably refactor that as a utility exported from (chibi filesystem),
which provides those low-level file-descriptor operators.

In the original plan for R7RS large this would have been part of the
Green (non-portable) docket, although this functionality seems missing
I'm not sure where this falls in the current R7RS large plans but it
should definitely be included.

-- 
Alex

--
You received this message because you are subscribed to the Google Groups "chibi-scheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chibi-scheme...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/chibi-scheme/CA%2BA2iZbSAnMR%3DRTB-Cm8nOXxFHNGC-M6XGus7MQt42C1hnKpaw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages