From bd0582656e9c78d7977cb1ece7b47e542552d230 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 18 Aug 2023 14:49:10 +0200 Subject: lxc_rootfs_debootstrap: discard chroot command output on zero verbosity --- lxc_rootfs_debootstrap | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lxc_rootfs_debootstrap b/lxc_rootfs_debootstrap index fcb21dd..71e79ef 100755 --- a/lxc_rootfs_debootstrap +++ b/lxc_rootfs_debootstrap @@ -314,6 +314,14 @@ class Bootstrapper: if self._verbose > 1: sys.stderr.write('Executing in chroot: %s\n' % cmdline) + # discard command's stdout/err on zero verbosity, as there's no general + # way to make all of them quiet + # failures should still be detected via return codes + if (self._verbose == 0 and + not any((it in kwargs for it in ('stdout', 'stderr', 'capture_output')))): + kwargs['stderr'] = subprocess.DEVNULL + kwargs['stdout'] = subprocess.DEVNULL + return subprocess.run(['chroot', self._root_path] + cmdline, check = True, **kwargs) parser = argparse.ArgumentParser(description = description) -- cgit v1.2.3