From 5594b37d4e925c3a82ac811337685a8ff3ec9993 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Wed, 13 May 2026 22:51:50 +0300 Subject: [PATCH] Improvements to named-pipes and shell libraries --- Makefile | 20 +++++++------------- retropikzel/named-pipes.scm | 3 --- retropikzel/named-pipes/VERSION | 2 +- retropikzel/shell.scm | 28 +++++++++++----------------- retropikzel/shell.sld | 1 + retropikzel/shell/VERSION | 2 +- 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 49ff5dd..90b71e3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ SCHEME=chibi -DOCKER_TAG=latest -IMAGE=${SCHEME}:${DOCKER_TAG} +DOCKER_TAG=head RNRS=r7rs LIBRARY=system AUTHOR=Retropikzel @@ -43,7 +42,7 @@ testfiles: package rm -rf .tmp mkdir -p .tmp cp -r test-resources .tmp/ - cp -r retropikzel .tmp/ + if [ "${RNRS}" = "${R6RS}" ]; then cp -r retropikzel .tmp/; fi # R6RS testfiles printf "#!r6rs\n(import (except (rnrs) remove) (srfi :64) (foreign c) (retropikzel ${LIBRARY}))" > .tmp/test.sps cat ${TESTFILE} >> .tmp/test.sps @@ -53,28 +52,23 @@ testfiles: package cp -r ../foreign-c/foreign .tmp/ cp -r ../generated-foreign-c-libraries/c2foreign-c .tmp/ cp ${PKG} .tmp/ - cd .tmp && if [ "${RNRS}" = "r6rs" ]; then snow-chibi --impls=generic install --always-yes --install-source-dir=. --install-library-dir=. ${PKG}; fi - cd .tmp && if [ "${RNRS}" = "r6rs" ]; then akku install akku-r7rs; fi test: testfiles cd .tmp && \ COMPILE_R7RS=${SCHEME} \ CSC_OPTIONS="${CSC_OPTIONS}" \ - compile-r7rs ${LIB_PATHS} \ - -o test-program \ - test.${SFX} + compile-r7rs ${LIB_PATHS} -o test-program test.${SFX} cd .tmp && ./test-program test-docker: testfiles cd .tmp && \ + TEST_R7RS_DEBUG=1 \ + DOCKER_TAG=${DOCKER_TAG} \ COMPILE_R7RS=${SCHEME} \ CSC_OPTIONS="${CSC_OPTIONS}" \ - SNOW_PACKAGES="srfi.64 foreign.c" \ + SNOW_PACKAGES="srfi.64 srfi.170 foreign.c retropikzel.system retropikzel.named-pipes ${PKG}" \ APT_PACKAGES="${APT_PACKAGES}" \ - test-r7rs \ - -o test-program \ - test.${SFX} \ - ${PKG} + test-r7rs -o test-program test.${SFX} clean: git clean -X -f diff --git a/retropikzel/named-pipes.scm b/retropikzel/named-pipes.scm index 106b9fa..89b5cf0 100644 --- a/retropikzel/named-pipes.scm +++ b/retropikzel/named-pipes.scm @@ -36,9 +36,6 @@ (lambda (msg return-code) (when (and (number? return-code) (< return-code 0)) - (display "HERE: ") - (write return-code) - (newline) (c-perror (string->c-bytevector msg)) (error msg return-code)) return-code)) diff --git a/retropikzel/named-pipes/VERSION b/retropikzel/named-pipes/VERSION index 6d7de6e..21e8796 100644 --- a/retropikzel/named-pipes/VERSION +++ b/retropikzel/named-pipes/VERSION @@ -1 +1 @@ -1.0.2 +1.0.3 diff --git a/retropikzel/shell.scm b/retropikzel/shell.scm index 3ea04ae..cabeb4c 100644 --- a/retropikzel/shell.scm +++ b/retropikzel/shell.scm @@ -1,24 +1,18 @@ -(define-c-library libc '("stdlib.h" "stdio.h" "unistd.h") #f '()) -(define-c-procedure c-tempnam libc 'tempnam 'pointer '(pointer pointer)) - (define previous-exit-code #f) (define (shell cmd) (when (not (string? cmd)) (error "shell: cmd must be string" cmd)) - (let* ((temp-prefix (string->c-bytevector "npcmd")) - (temp-name (lambda () - (c-bytevector->string (c-tempnam (c-bytevector-null) - temp-prefix)))) - (input-path (temp-name)) - (shell-command (string-append cmd - " 1> " - input-path - " 2> " - input-path - " & "))) - (create-pipe input-path 0777) - (set! previous-exit-code (system shell-command)) - (pipe-read-string 64000 (open-input-pipe input-path #t)))) + (call-with-temporary-filename + (lambda (input-path) + (let* ((shell-command (string-append cmd + " 1> " + input-path + " 2> " + input-path + " & "))) + (create-pipe input-path 0777) + (set! previous-exit-code (system shell-command)) + (pipe-read-string 64000 (open-input-pipe input-path #t)))))) (define (lines->list port result) (let ((line (read-line port))) diff --git a/retropikzel/shell.sld b/retropikzel/shell.sld index 213710c..58b0868 100644 --- a/retropikzel/shell.sld +++ b/retropikzel/shell.sld @@ -4,6 +4,7 @@ (scheme write) (scheme read) (scheme file) + (srfi 170) (foreign c) (retropikzel system) (retropikzel named-pipes)) diff --git a/retropikzel/shell/VERSION b/retropikzel/shell/VERSION index 7dea76e..6d7de6e 100644 --- a/retropikzel/shell/VERSION +++ b/retropikzel/shell/VERSION @@ -1 +1 @@ -1.0.1 +1.0.2