aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-08-27 08:23:41 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-08-27 14:30:17 +0200
commit712ca3235329b049bf9a4e481ba38a4c64768e8b (patch)
treef86aadc4bda26ca26f88ec3e0357c0185e25e6b1
parente0be6bc2f4762ba8c090aef0f8b85a47a4243356 (diff)
downloadpasst-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar.gz
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar.bz2
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar.lz
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar.xz
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.tar.zst
passt-712ca3235329b049bf9a4e481ba38a4c64768e8b.zip
seccomp.sh: Try to account for terminal width while formatting list of system calls
Avoid excess lines on wide terminals, but make sure we don't fail if we can't fetch the number of columns for any reason, as it's not a fundamental feature and we don't want to break anything with it. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rwxr-xr-xseccomp.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/seccomp.sh b/seccomp.sh
index 052e1c8..38aa826 100755
--- a/seccomp.sh
+++ b/seccomp.sh
@@ -242,7 +242,10 @@ for __p in ${__profiles}; do
__calls="$(sed -n 's/[\t ]*\*[\t ]*#syscalls\(:'"${__p}"'\|\)[\t ]\{1,\}\(.*\)/\2/p' ${IN})"
__calls="${__calls} ${EXTRA_SYSCALLS:-}"
__calls="$(filter ${__calls})"
- echo "seccomp profile ${__p} allows: ${__calls}" | tr '\n' ' ' | fmt -t
+
+ cols="$(stty -a | sed -n 's/.*columns \([0-9]*\).*/\1/p' || :)" 2>/dev/null
+ case $cols in [0-9]*) col_args="-w ${cols}";; *) col_args="";; esac
+ echo "seccomp profile ${__p} allows: ${__calls}" | tr '\n' ' ' | fmt -t ${col_args}
# Pad here to keep gen_profile() "simple"
__count=0