From 3765d3b7606c18116a5feec748a632afa85123b8 Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Sat, 15 Feb 2014 09:55:33 -0500 Subject: [PATCH] Enable custom timestamp formats via env flag --- tcat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tcat.c b/tcat.c index 1e338fd..fe742ed 100644 --- a/tcat.c +++ b/tcat.c @@ -11,7 +11,8 @@ enum { }; static const char program_name[] = "tcat"; -static const char format[] = "%FT%T%z\t"; +static const char env_flag[] = "TCAT_FORMAT"; +static const char *format = "%FT%T%z\t"; static void io_error(FILE* file) { if (feof(file)) { @@ -90,6 +91,11 @@ int main(int argc, char** argv) { fprintf(stderr, "Warning: input is from TTY\n"); } + char *format_env = getenv(env_flag); + if (format_env) { + format = format_env; + } + int last = '\n'; for(int c = fgetc(stdin); c != EOF; c = fgetc(stdin)) { if (last == '\n') {