diff --git a/CHANGELOG.md b/CHANGELOG.md index 531c84eb..d02a8e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ to fail. * Background color when alpha < 1.0 being wrong (https://codeberg.org/dnkl/foot/issues/249). +* `generate-alt-random.py` failing in containers. ### Security diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 202c99c5..2e51082b 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -37,11 +37,17 @@ def main(): opts = parser.parse_args() out = opts.out if opts.out is not None else sys.stdout - lines, cols, height, width = struct.unpack( - 'HHHH', - fcntl.ioctl(sys.stdout.fileno(), - termios.TIOCGWINSZ, - struct.pack('HHHH', 0, 0, 0, 0))) + try: + lines, cols, height, width = struct.unpack( + 'HHHH', + fcntl.ioctl(sys.stdout.fileno(), + termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + except OSError: + lines = None + cols = None + height = None + width = None if opts.rows is not None: lines = opts.rows @@ -50,6 +56,9 @@ def main(): cols = opts.cols width = 8 * cols # PGO help binary hardcodes cell width to 8px + if lines is None or cols is None or height is None or width is None: + raise Exception('could not get terminal width/height; use --rows and --cols') + # Number of characters to write to screen count = 256 * 1024**1