-
Christoph Anton Mitterer authored
In order to parse the annotated output it would be nice if that would contain information about the prefix (format string) it uses. This is done by printing another line similar to the “header”, which gives the version information, thereby again altering the output format. Tools, that parse the annotated output should in principle assume that any lines `I: …` without a prefix may be included in the output (in principle at any point). In order to no need a shell variable (which might unintentionally get passed on to the actually executed program, see commit 0d5ca640 (“annotate-output: prevent `PROGNAME`- variable from leaking to command”)), the construct with a definition function is used again. The double-escaping using GNU `printf`’s `%q`-conversion-specifier is necessary because once it’s needed for the `eval` and once to have it escaped as output. The leading `+`, if any, is stripped off because it’s not really part of the prefix format string, but only needed for the `date`-utility. The `get_prefix()`-function could have been defined to always print a trailing `\n`, thereby avoiding the need for the final `printf '\n'`, but the, the function – should it ever be used for some further purpose – would not return the real prefix. Signed-off-by:
Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Christoph Anton Mitterer authoredIn order to parse the annotated output it would be nice if that would contain information about the prefix (format string) it uses. This is done by printing another line similar to the “header”, which gives the version information, thereby again altering the output format. Tools, that parse the annotated output should in principle assume that any lines `I: …` without a prefix may be included in the output (in principle at any point). In order to no need a shell variable (which might unintentionally get passed on to the actually executed program, see commit 0d5ca640 (“annotate-output: prevent `PROGNAME`- variable from leaking to command”)), the construct with a definition function is used again. The double-escaping using GNU `printf`’s `%q`-conversion-specifier is necessary because once it’s needed for the `eval` and once to have it escaped as output. The leading `+`, if any, is stripped off because it’s not really part of the prefix format string, but only needed for the `date`-utility. The `get_prefix()`-function could have been defined to always print a trailing `\n`, thereby avoiding the need for the final `printf '\n'`, but the, the function – should it ever be used for some further purpose – would not return the real prefix. Signed-off-by:
Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>