HTML Tidy  5.1.25
The HTACG Tidy HTML Project
Running tidy in scripts

If you want to run Tidy from a Perl, bash, or other scripting language you may find it of value to inspect the result returned by Tidy when it exits:

  • 0 = if everything is fine
  • 1 = if there were warnings and
  • 2 = if there were errors.

Example Perl script

1 if (close(TIDY) == 0) {
2  my $exitcode = $? >> 8;
3  if ($exitcode == 1) {
4  printf STDERR "tidy issued warning messages\n";
5  } elsif ($exitcode == 2) {
6  printf STDERR "tidy issued error messages\n";
7  } else {
8  die "tidy exited with code: $exitcode\n";
9  }
10 } else {
11  printf STDERR "tidy detected no errors\n";
12 }