sanitycheck: leave non-tty terminal unmodified on exit

The terminal configuration should not be reset on exit if
sanitycheck's output is being directed to something that mediates the
terminal control, such as a pager.  Only do the reset if stdout is
interactive.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
diff --git a/scripts/sanitycheck b/scripts/sanitycheck
index f238cef..7970fc7 100755
--- a/scripts/sanitycheck
+++ b/scripts/sanitycheck
@@ -4365,4 +4365,5 @@
     try:
         main()
     finally:
-        os.system("stty sane")
+        if os.isatty(1): # stdout is interactive
+            os.system("stty sane")