Re: defines varname { [values]... } prog...

From: Carlos Eduardo <carana2099_at_gmail.com>
Date: Fri, 24 May 2024 13:19:12 -0300

(Resending to the mailing list, because "Reply to All" is not the
default option in Gmail's UI).

The goal isn't to prevent cmdB from seeing "${foo}" at all; it's to
prevent the 'multisubstitute' from replacing "$foo" in the second
instance of $cfiles, making it possible for each program operate on a
different set of files.

If we have a "${foo}.c" file in the directory, we'd like for both the
block inside backtick FOO { cmdA ... } and cmdB to operate on it.
Without "defines" (or some other way to protect the result of elglob
from the substitution mechanism — in the previous message, I suggested
storing it as a netstring in the environment), cmdA may operate on
"${foo}.c" and cmdB, on something like "operation successful.c".

---
#!/bin/execlineb -P
# pretend the two next commands are elglob
define thearr "a.c ${foo}.c"
define -sd " " files $thearr
backtick FOO { echo $files }
foreground
{
    importas foo FOO
    foreground { echo 1 }
    forx -E f { $files } s6-quote $f
}
multisubstitute {
    importas foo FOO
    # pretend the next command is defines
    define -sd " " newfiles $thearr
}
foreground { echo 2 }
forx -E f { $newfiles } s6-quote $f
---
Output:
1
"a.c"
"a.c ${foo}.c.c"
2
"a.c"
"${foo}.c
Received on Fri May 24 2024 - 18:19:12 CEST

This archive was generated by hypermail 2.4.0 : Fri May 24 2024 - 18:19:53 CEST