Skip to content

Commit

Permalink
Merge pull request #8 from stephenmathieson/format-via-env
Browse files Browse the repository at this point in the history
Enable custom timestamp formats via env flag
  • Loading branch information
marcomorain committed Feb 26, 2014
2 parents 32c0beb + 3765d3b commit 3d5c432
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 3d5c432

Please sign in to comment.