***iyzsong-alt is now known as iyzsong
<jpoiret>attila_lendvai: for extended examples you might want to check Guix's (guix inferior) or (gnu installer utils)'s "run-external-command-with-handler" <attila_lendvai>jpoiret, your fixes in that bug report... they will not affect the guile interface, right? (except for fixing misbehavior) <jpoiret>"fixing misbehavior" == affecting the guile interface, no? <jpoiret>well, technically not, yeah. The last patchset does change the API a bit though <jpoiret>since spawning a child process can now raise system exceptions, whereas in the past it only returned the pid of the child <attila_lendvai>jpoiret, you mean the exceptions instead of return codes, right? that's managable. i just don't want to invest a lot into learning pipes in scheme right before a potential major API overhaul... :) <jpoiret>if that's what you're worried about, don't worry then, no major change <civodul>though IIUC correctly, it's like posix_spawn: the interface offers a predefined set of setup operations one can do before exec, right? <jpoiret>yes, but io_uring could offer a way bigger api <kreyren> http://ix.io/4b6C Running this code results in the wrong formatting where it strips the `--` from `--work-tree=` -> Howddya fix tht <jpoiret>you don't have a format specifier in your format string <jpoiret>no, it says you want format to return the value of the format result <kreyren>fwiw i tried append-string before with same result <kreyren>so like `(format #f ~a "--work-tree="...` ? <jpoiret>the signature is (format PORT-OR-BOOL FORMAT-STRING ARGS ...) <jpoiret>no, (format #f "--work-tree=~a" repository) <kreyren>error: unknown option `work-tree=/home/kreyren/Repositories/guix/automation/..' <jpoiret>are you sure work-tree is an option for git checkout? <kreyren>it's option for `git`, seems to work now thanks ^-^ ***M6piz7wk[m] is now known as KREYREN
<KREYREN>Howddya make a loop that runs twice and sets the variable `variable` on USERNAME and TOKEN? <KREYREN> (format #t "Required variable '~a' is not defined" variable) <drakonis>have you considered recursion or using do? <KREYREN>the recursion way sounds more fun and potentially nicer code though *KREYREN is noob in guile <taw10>Why does it have to run twice? <flatwhatson>KREYREN: (for-each (lambda (variable) <your code here>) '("USERNAME" "TOKEN")) <flatwhatson>but you're better off making your code into a function, say (define (get-variable variable) <your code here>) <KREYREN>taw10: to check if both variables (USERNAME and TOKEN) are set <flatwhatson>make it return the value from the variable (use a let to capture the return of getenv and return it afterwards) <flatwhatson>then your code could be something like (let ((username (get-variable "USERNAME")) (token (get-variable "TOKEN"))) ...) <KREYREN><flatwhatson> "make it return the value from..." <- why is that beneficial? <KREYREN>also these variables are designed to be publicly available instead of within a scope <rekado>why do you define them at all when you aren’t using them? <rekado>also: no need for defines when you can use let. <KREYREN>rekado: my scripting brain tells me to do sanity check to make sure that they are available and use them later <rekado>but you’re not using the defined values. <KREYREN>rekado: so you think something like this instead? <KREYREN>so that it's a guile script that can be used in the CI/CD <rekado>so pretty much what flatwhatson wrote above <rekado>BTW: append-string doesn’t exist; it’s called string-append <KREYREN>why is that wrapped in (define) when it's expected to run immediately <rekado>no difference; define first run later, or run right away — your call <KREYREN>shows error message and then lets the fatal error cause chaos <KREYREN>rekado: btw. you marked the two `load`s as ugly.. is there a non-ugly way? <KREYREN>beyond using recursion that avoids the duplicate code <KREYREN>you can use modules for local things? O.o <rekado>modules are how you organize code in Guile. <rekado>local/remote doesn’t factor in it. <KREYREN>hotfixes.scm - compensation for the lack of implementation in guile-git library until that is addressed <KREYREN>common.scm - things used across all other scripts <rekado>turn them into modules, then import them <rekado>this also gives you much more flexibility in terms of where files are located <rekado>as long as the modules are on the load path they can be used <rekado>no need for this relative file lookup business <KREYREN>turn them into modules how? like define libraries with that functionality_ <KREYREN>for them to be in the load path they would have to be in GUILE_LOAD_PATH env variable right <rekado>I suggest looking at the Guile Reference manual <rekado>in your info reader: i define-module RET <KREYREN>rekado: eh? what am i supposed to see on that? O.o <KREYREN>also the common.scm currently has only the `(define %repodir (string-append (dirname (current-filename)) "/.."))` <rekado>your info reader will jump to “Creating Guile Modules”, which is a good starting point if you want to learn how to define modules and all that. <KREYREN>i know how to define modules but i don't understand the beneficial usecase <tricon>KREYREN: you aren't dependent upon relative load paths. it's good practice to isolate contexts, domains, etc. into modules. <KREYREN>and the only way to use those modules is using GUILE_LOAD_PATH right *KREYREN goes to figure out the implementation then <tricon>KREYREN: GUILE_LOAD_PATH or, if invoking manually, ~guile -L path-to-modules file.scm~ <KREYREN>ehh how do i get the let things as input to the procedure? <KREYREN>like i figured out that i can get rid of the parenthesis in the definition but that will also get rid of the docstring <rekado>you can pass anything to a procedure as long as it binds variables <rekado>(lambda (foo bar baz . rest) …) binds three arguments to the variables “foo”, “bar”, and “baz”, and whatever else is passed to it is bound to the variable “rest”. <rekado>(define whatever (lambda …)) is binding the procedure to the name “whatever” <rekado>that’s the same as (define (whatever foo bar baz . rest) …) <rekado>if you don’t want to use positional arguments search the manual for keyword arguments <KREYREN>What is the prettier way to write (when (= variable "") ...) ? <KREYREN>... i wrote the example code wrong my bad >_< <rekado>but getenv returns #f when the variable is not set <KREYREN>was hoping `non-empty?` would be a thing <rekado>(define non-empty (negate string-null?)) <rekado>it’s probably not a good idea to use the empty string when you can use a different value <rekado>you can also use “unless” instead of “when” <rekado>I wouldn’t use #:optional with #:key <KREYREN>what would you use to achieve the optional pushing? <rekado>it will be #t unless set to something else <KREYREN>oh what's the alternative to like unset variable then? *KREYREN is confusing it with common lisp probably <rekado>by default an unspecified keyword argument will be #false <KREYREN>assuming that `empty?` will work on it <KREYREN>like doing (when (empty? source-repo) (error "...")) <rekado>(define* (meh #:key foo bar baz) …) accepts three optional keyword arguments. If they are not specified they are #f. <rekado>you can also give them an error expression as the default value <rekado>(define* (meh #:key (foo (error "foo is required"))) …) <KREYREN>can i combine? like (define* (meh #:key (foo bar) baz) ? <rekado>that would make “bar” the default value for “foo” if it isn’t specified when calling “meh”. <KREYREN>bar being defaul value for foo is expected, but i don't know if it's sane to expect baz to be #f ? <rekado>if you don’t provide a default value the default will always be #f