[dev] switching to rc: filename expansion ?

From: Marc Chantreux <eiro_AT_phear.org>
Date: Mon, 25 Nov 2019 22:23:51 +0100

hello people,

some of the things i really enjoy in zsh comes from rc
(setopt rcquotes, the ^ expansion, the alternative syntax
for constrol structures that are close to rc, ...) but
both the codebase and the binary are very large.

i'm experimenting replacing zsh by rc when the rc
counterpart is good enough. but it seems i reach the
limits of rc very soon. example

in an mkfile, i can write things like that

    PUBLIC = `{ echo *.md }
    PAGES = ${PUBLIC:%.md=pub/%.html}

in zsh, i can write

    ls *.md
    set -- *.md(:r) # (:r) will remove the tailing .md
    pages=( pub/$^_AT_.html )
    print -l $pages

as a result, i get

    l'autre.md
    this is.md
    pub/l'autre.html
    pub/this is.html

there is nothing like the ':' modifiers or ${p%.md}
alike expansions in rc so i try to figure out what
would be an idiomatic way to do that in rc.

i tried

    pages=(`{ ls *.md | sed 's/md$/html/; s/md''/html''/' })
    echo pub/^$pages

which gives me

    pub/l'autre.html pub/this pub/is.html

close ... but wrong :) i can add klugdes around it but i
feel i missed something. Any advice when it comes to applying
a transformation to a list with rc?

regards
marc
Received on Mon Nov 25 2019 - 22:23:51 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 25 2019 - 22:36:10 CET