#!/usr/bin/python3

import sys
import os

try:
    sys.path.insert(0, '/usr/lib/supportutils-scrub/')
    from supportutils_scrub.main import main
except KeyboardInterrupt:
    raise SystemExit()
except ImportError as e:
    print(f"Error importing the main module: {e}")
    sys.exit(1)

if __name__ == '__main__':
    _exit_code = 0
    try:
        main()
    except KeyboardInterrupt:
        print("\n[!] Interrupted.", file=sys.stderr)
        _exit_code = 1
    except SystemExit as e:
        _exit_code = e.code if isinstance(e.code, int) else 1
    except Exception as e:
        print(f"An error occurred during execution: {e}", file=sys.stderr)
        _exit_code = 1
    finally:
        sys.stdout.flush()
        sys.stderr.flush()
        os._exit(_exit_code)
