|
From: | Dennis Ruffer |
Subject: | Re: [gforth] How to get stdout into gforth |
Date: | Fri, 26 Jan 2018 15:15:37 -0800 |
Almost, but there’s a critical mistake covering up a problem. ( target ) COUNT coverage_out C@ /STRING TYPE Produces: CTS Tests API-NDK Coverage Report: file:///home/druffer/master/out/host/linux-x86/cts-api-coverage /test-coverage.html ok Which has an extra new line. ;( DaR From: Dennis Ruffer Thanks everyone for the suggestions. While OPEN-PIPE sounds like the best place for me to investigate, it turns out that the Makefile logic I was trying to convert didn’t actually need to pull the pwd output into gforth. I translated: echo $(1): file://$$(cd $(dir $@); pwd)/$(notdir $@) from Makefile to gforth as: COMBINED-STRING print_coverage_out_dir +," cd " coverage_out +, +," ; pwd" CR ( a n ) TYPE ." : file://" print_coverage_out_dir COUNT SYSTEM $? THROW ( target ) COUNT coverage_out COUNT /STRING TYPE And I got: CTS Tests API-NDK Coverage Report: file:///home/druffer/master/out/host/linux-x86/cts-api-coverage Identical to the original, so it is sufficient, for now. I have some other work where OPEN-PIPE might be useful, but I’ve got enough for the immediate issue to move onto the next problems. Thanks again! DaR From: Anton Ertl On Thu, Jan 25, 2018 at 02:49:02PM -0800, Dennis Ruffer wrote: > Say I want to do something like this: > > s" cd .. ; pwd" system /home/druffer > > How do I get the output of pwd back into gforth? You would use OPEN-PIPE instead of SYSTEM, but I don't have an example. > I see infile-execute, but I don’t see an examples for me to try. INFILE-EXECUTE is for making any file temporarily the standard input (so that KEY reads from this file). But for your problem, you need to get the output of pwd into gforth. A pipe does that. > Is that the right path, or is there another? You could use the C interface to call chdir(), getcwd(), and then somehow chdir() back. - anton |
[Prev in Thread] | Current Thread | [Next in Thread] |