<dadinn>I am trying to read and parse the output of a shell command. What is the best way to do this? <dadinn>I assume the problem is either with read-string or close-pipe? <lilyp>yep, you're not actually passing content to it <dadinn>lampilelo: apologies, indeed that's a typo in my example, assume that content is the second argument there <lampilelo>what doesn't work? zpool exits with non-zero code? <dadinn>the exit status of the command is zero <dadinn>I get a backtrace printed it complains that something is wrong in close-pipe. In procedure %port-property: Wrong type argumen in position 1 (expecting open port): #<closed: file 562671aca3f0> <lampilelo>i think that's because you used "pipe" as a variable name <lampilelo>on close-pipe it tries to close a pipe procedure instead of that variable <lampilelo>i mean it works if pipe is used as a variable name everywhere, maybe you have a typo somewhere? <lampilelo>it looks like the pipe is already closed and close-pipe doesn't like that <dadinn>lampilelo: you mean that I don't have to close it manually? <lampilelo>idk, when i test it with ls it just works, maybe check with (port-closed? pipe) before trying to close <dadinn>lampilelo: arrgh, sorry I was accidentally closing it twice! <lampilelo>and i was wondering how and why would it close prematurely <dadinn>lampilelo: ok, everything seems to work, I fetch the correct content, but the match returns #f, which means the regex is wrong <dadinn>argh! it seems string-match applies for the whole string, and I'm using ^ and $ symbols as line ending <dadinn>I think I should be using regexp-exec instead with regexp/newline option <lampilelo>dadinn: you can use dynamic-wind to run any cleanup code <dadinn>lampilelo: not familiar with dinamic-wind, do you have some docs which describe how it works? <dadinn>oh sorry, I see the guile docs have some examples too <dadinn>was confused by the C-specific aspect of it in the first part <lampilelo>it's kinda like try-catch-finally block from python, without the "catch" part <lampilelo>so the out-guard will run on normal exit and on error <lampilelo>(let ((pipe ...)) (dynamic-wind (const #t) thunk (lambda () (close-pipe pipe)))) <dadinn>what's that (const #t) part for? <lampilelo>equivalent to (lambda _ #t), it's a placeholder for in-guard <dadinn>awesome, I think I will need this a lot! I've been missing the finally blocks a lot recently <dadinn>tried working around it with catch instead, but it was quite clumsy ***janneke_ is now known as janneke
***dekenevs is now known as kitzman
<sneek>I've been running for 20 days <sneek>This system has been up 14 weeks, 5 days, 16 minutes <rmrfchik>hi, I have guile-2.2 (raspberrypi). what's the best way to use C .a library? <lilyp>You can also use FFI if you feel like it. <lilyp>You're only really missing (system foreign-library) <lilyp>but dynamic-link etc. have existed in 2.2 as well <lilyp>oh, then you need to compile it to a shared object first <RhodiumToad>if you only have a .a file and it wasn't compiled for PIC, then you're a bit stuck <lilyp>alternatively you can write a guile program that writes a c program, that links against your static library <lloda>it isn't pretty but it's just internal and it fixes a recurrent issue