This is very frustrating. I can obtain my Linux group ID and assign it to a Latex counter.
When using the \bash..\END construct it works, but when using splice construct it does not work. I'll show MWE to explain more.
This works. I get the group ID from bash and set it to a Latex counter:
\documentclass{article}
\usepackage{bashful}
\newcounter{c}
\begin{document}
\bash
id -g
\END
\setcounter{c}{\bashStdout}
my group ID is \arabic{c}
\end{document}
compile pdflatex -shell-esc foo.tex and the PDF file shows
my group ID is 1000
This does not work:
\documentclass{article}
\usepackage{bashful}
\newcounter{c}
\begin{document}
\setcounter{c}{\splice{id -g}}
my group ID is \arabic{c}
\end{document}
The compile error is
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Missing number, treated as zero.
<to be read again>
\immediate
l.8 \setcounter{c}{\splice{id -g}}
?
It looks like the counter is being set before bash is run and returned the 1000 value. So I need to tell it to expand before? I do not understand the expand commands, but I tried
\expandafter\setcounter{c}{\splice{id -g}}
and
\setcounter{c}{\expandafter\splice{id -g}}
but nothing is working. It is clearly an evaluation order issue. Is there a way to make splice work in the above? I'd like to learn why it is not working.
Package reference is here
This is what the documentaion says about splice

\setcounterhas to expand to a number, not be some arbitrary non expandable code that eventually would typeset a number,\setcounter{c}{\def\foo{3}\foo}doesn't work either. – David Carlisle Jul 29 '15 at 09:15id -gfor illustrations. – Nasser Jul 29 '15 at 09:20\setcounterI would guess. – David Carlisle Jul 29 '15 at 09:21\shellcommandwhich works! but it has problem when I usebreqnpackage, which I must use. I posted separate question on that. Latex is so hard. – Nasser Jul 29 '15 at 09:23