![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
Hey list, I'd like to include the output of a command. I am using the following to define the command, \def\BazaarRevision{\cldcontext{os.resultof"bzr revno | tr -d '\\n'"}} and the following to use the output of the command, \BazaarRevision A concern I have is whether this command is executed multiple times during the typesetting process when it need only be done once with the result cached. If this is indeed the case, does anyone have any suggestions? -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sun, 4 Mar 2012, Kip Warner wrote:
Hey list,
I'd like to include the output of a command. I am using the following to define the command,
\def\BazaarRevision{\cldcontext{os.resultof"bzr revno | tr -d '\\n'"}}
and the following to use the output of the command,
\BazaarRevision
A concern I have is whether this command is executed multiple times during the typesetting process when it need only be done once with the result cached. If this is indeed the case,
Yes.
does anyone have any suggestions?
The cleaner way is to seperate the setup and use. For example: \def\initilizebazaar {\ctxlua{context.setevalue( "usebazaarrevision", os.resultof"bzr revno | tr -d '\\n'")}} \appendtoks \initilizebazaar \to \everystarttext and then use can use \usebazaarrevision in the main text. If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example: \def\BazaarRevision {\ctxlua{context.setevalue( "BazaarRevision", os.resultof"bzr revno | tr -d '\\n'")}% \BazaarRevision} Aditya
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote:
If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example:
\def\BazaarRevision {\ctxlua{context.setevalue( "BazaarRevision", os.resultof"bzr revno | tr -d '\\n'")}% \BazaarRevision}
Hey Aditya. I tried the automagic method, but ConTeXt bails: ! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } ... l.58 ! ==> Fatal error occurred, no output PDF file produced! mtx-context | fatal error: return code: 1 Based on what I saw from htop, it looks like it running the command into the ground over and over again which is the exact opposite of what we are trying to do. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 5 Mar 2012, Kip Warner wrote:
On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote:
If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example:
\def\BazaarRevision {\ctxlua{context.setevalue( "BazaarRevision", os.resultof"bzr revno | tr -d '\\n'")}% \BazaarRevision}
Hey Aditya. I tried the automagic method, but ConTeXt bails:
! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 }
\BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 }
\BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 }
... l.58
The attached file works at my end.
Based on what I saw from htop, it looks like it running the command into the ground over and over again which is the exact opposite of what we are trying to do.
No. It is defining \BazaarVersion once and then reusing the result. Add \loggingall to your file to see what is happening. Aditya
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Mon, 2012-03-05 at 22:05 -0500, Aditya Mahajan wrote:
The attached file works at my end.
It works at my end as well, but just not as part of my book.
No. It is defining \BazaarVersion once and then reusing the result. Add \loggingall to your file to see what is happening.
It still bails. This is what I see with \loggingall placed in the environment file. ... {vertical mode: \tracingstats} {\tracingpages} {\tracingoutput} {\tracinglostchars} {\tracingmacros} {\tracingparagraphs} {\tracingrestores} {\showboxbreadth} {\showboxdepth} {\tracinggroups} {\tracingifs} {\tracingscantokens} {\tracingnesting} {\tracingassigns} {into \tracingassigns=2} {\errorstopmode} {\tracingonline} {changing \tracingonline=1} ! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } ... l.60 ! ==> Fatal error occurred, no output PDF file produced! mtx-context | fatal error: return code: -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 5 Mar 2012, Kip Warner wrote:
On Mon, 2012-03-05 at 22:05 -0500, Aditya Mahajan wrote:
The attached file works at my end.
It works at my end as well, but just not as part of my book.
Hard to debug without the actual test file.
No. It is defining \BazaarVersion once and then reusing the result. Add \loggingall to your file to see what is happening.
It still bails. This is what I see with \loggingall placed in the environment file.
Use {\loggingall \BazaarRevision } in your file and attach the output of the log file. Aditya
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Mon, 2012-03-05 at 22:15 -0500, Aditya Mahajan wrote:
Use
{\loggingall \BazaarRevision }
I added the above to my environment, but this is all I see. I think this is the same as last time: <+ /usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.lua>) {vertical mode: \tracingstats} {\tracingpages} {\tracingoutput} {\tracinglostchars} {\tracingmacros} {\tracingparagraphs} {\tracingrestores} {\showboxbreadth} {\showboxdepth} {\tracinggroups} {\tracingifs} {\tracingscantokens} {\tracingnesting} {\tracingassigns} {into \tracingassigns=2} {\errorstopmode} {\tracingonline} {changing \tracingonline=1} ! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } \BazaarRevision ...ltof"bzr revno | tr -d '\\n'")} \BazaarRevision l.4 } ... l.61 ! ==> Fatal error occurred, no output PDF file produced! mtx-context | fatal error: return code: 1 -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Mon, 2012-03-05 at 22:38 -0500, Aditya Mahajan wrote:
Can you attach your complete log file?
Attached. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 5 Mar 2012, Kip Warner wrote:
On Mon, 2012-03-05 at 22:38 -0500, Aditya Mahajan wrote:
Can you attach your complete log file?
Attached.
The error is not due to the macro \BazaarRevision. The log file shows that the group (for {\loggingall \BazaarRevison}) is closed properly; the error is displayed after that. So, something else in your setup is causing the error. Aditya
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Mon, 2012-03-05 at 22:50 -0500, Aditya Mahajan wrote:
The error is not due to the macro \BazaarRevision. The log file shows that the group (for {\loggingall \BazaarRevison}) is closed properly; the error is displayed after that. So, something else in your setup is causing the error.
It doesn't bail unless I replace the previous definition with yours. Here is an example of its usage from my source: \setupinteraction [state=start, color=colour_link, contrastcolor=colour_link, focus=standard, title=Some Book (Bzr r\BazaarRevision), author=Some Book (Bzr r\BazaarRevision)] The rest of the book just has some \BazaarRevision scattered here and there, but I can't see anything unusual about their usage or context. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 5 Mar 2012, Kip Warner wrote:
On Mon, 2012-03-05 at 22:50 -0500, Aditya Mahajan wrote:
The error is not due to the macro \BazaarRevision. The log file shows that the group (for {\loggingall \BazaarRevison}) is closed properly; the error is displayed after that. So, something else in your setup is causing the error.
It doesn't bail unless I replace the previous definition with yours. Here is an example of its usage from my source:
\setupinteraction [state=start, color=colour_link, contrastcolor=colour_link, focus=standard, title=Some Book (Bzr r\BazaarRevision), author=Some Book (Bzr r\BazaarRevision)]
Why don't you use the first version (\initializebazaarversion and \usebazaarversion)? \def\initializeBazaar {\ctxlua{context("\\global\\edef\\BazaarRevision{\%s}", os.resultof"bzr revno | tr -d '\\n'")}} \initializeBazaar \setupinteraction [state=start, color=colour_link, contrastcolor=colour_link, focus=standard, title=Some Book (Bzr r\BazaarRevision), author=Some Book (Bzr r\BazaarRevision)] \starttext Hello \BazaarRevision Bye \stoptext
The rest of the book just has some \BazaarRevision scattered here and there, but I can't see anything unusual about their usage or context.
It helps if you try to create a minimal example. Aditya
![](https://secure.gravatar.com/avatar/e4119be23c6b43ebdb1041bb53ac9e67.jpg?s=120&d=mm&r=g)
On Tue, 2012-03-06 at 00:04 -0500, Aditya Mahajan wrote:
Why don't you use the first version (\initializebazaarversion and \usebazaarversion)?
\def\initializeBazaar {\ctxlua{context("\\global\\edef\\BazaarRevision{\%s}", os.resultof"bzr revno | tr -d '\\n'")}}
\initializeBazaar
Very good question. I suppose trying to get the automagic method to work doesn't matter since the above works fine. Thanks again Aditya. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com
participants (2)
-
Aditya Mahajan
-
Kip Warner