TransWikia.com

Unexpected result using sys_get_shell in argument of hypersetup

TeX - LaTeX Asked by Septatrix on March 7, 2021

I would like to include the content of an environment variable inside a PDFs metadata. (More specifically the commit inside of a CI pipeline). To do this I used an old(ish) macro of mine to get the value of environment variables using sys_get_shell:nnN + kpsewhich --var-value.

Surprisingly this works when storing the result inside an intermediate variable but not when using the output directly. The screenshot shows the metadata information as reported by TeXstudio.

enter image description here

MWE:

documentclass{article}

usepackage{hyperref}
usepackage{xparse}

ExplSyntaxOn

NewDocumentCommand getenv { o m }
{
    sys_get_shell:nnN { kpsewhich ~ --var-value ~ #2 } { } l_tmpa_tl
    tl_trim_spaces:N l_tmpa_tl
    IfNoValueTF { #1 }{
        tl_to_str:N l_tmpa_tl
    }{
        tl_set_eq:NN #1 l_tmpa_tl
    }
}

ExplSyntaxOff

getenv[LANG]{LANG}
hypersetup{
    pdfinfo={
        LangIndirect=LANG,
        LangDirect=getenv{LANG},
    },
}

begin{document}

ExplSyntaxOn
tl_to_str:N l_tmpa_tl
ExplSyntaxOff

end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP