From aa6327c3f630c9b7b7ceef8d07f3a57ca03cccf1 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 14 Jun 2022 19:12:53 +0200 Subject: Early-catch large show output with -interactive-print --- bwrap-files/entry.sh | 6 ------ bwrap-files/start.sh | 6 +++--- bwrap-files/workdir/Yahb2Defs.hs | 8 ++++++++ bwrap-files/workdir/entry.sh | 6 ++++++ 4 files changed, 17 insertions(+), 9 deletions(-) delete mode 100755 bwrap-files/entry.sh create mode 100644 bwrap-files/workdir/Yahb2Defs.hs create mode 100755 bwrap-files/workdir/entry.sh (limited to 'bwrap-files') diff --git a/bwrap-files/entry.sh b/bwrap-files/entry.sh deleted file mode 100755 index f9c4ad3..0000000 --- a/bwrap-files/entry.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -euo pipefail - -cd "$(dirname "$0")" - -ghcup --offline run -- ghci 2>&1 diff --git a/bwrap-files/start.sh b/bwrap-files/start.sh index 03bf77e..f0d0fa1 100755 --- a/bwrap-files/start.sh +++ b/bwrap-files/start.sh @@ -20,6 +20,7 @@ args=( --ro-bind "${ghcup_base}/bin" "${ghcup_base}/bin" --ro-bind "${ghcup_base}/ghc" "${ghcup_base}/ghc" --ro-bind "${ghcup_base}/cache" "${ghcup_base}/cache" + --ro-bind "${filesdir}/workdir" /workdir --setenv PATH "/bin:/usr/bin:${ghcup_base}/bin" --setenv GHCUP_INSTALL_BASE_PREFIX "$(dirname ${ghcup_base})" --proc /proc @@ -27,8 +28,7 @@ args=( --new-session --unshare-all --die-with-parent - --file 4 "/tmp/entry.sh" - /bin/bash "/tmp/entry.sh" + /bin/bash "/workdir/entry.sh" ) # Turn off core files @@ -40,4 +40,4 @@ ulimit -u 10000 # Limit memory to 500 MiB. ulimit -d $(( 500 * 1024 )) -exec bwrap "${args[@]}" 4<"${filesdir}/entry.sh" +exec bwrap "${args[@]}" diff --git a/bwrap-files/workdir/Yahb2Defs.hs b/bwrap-files/workdir/Yahb2Defs.hs new file mode 100644 index 0000000..c0dfbfd --- /dev/null +++ b/bwrap-files/workdir/Yahb2Defs.hs @@ -0,0 +1,8 @@ +module Yahb2Defs where + + +limitedPrint :: Show a => a -> IO () +limitedPrint x = + case splitAt 200 (show x) of + (s, "") -> putStrLn s + (s, _) -> putStrLn (take 197 s ++ "...") diff --git a/bwrap-files/workdir/entry.sh b/bwrap-files/workdir/entry.sh new file mode 100755 index 0000000..1a466da --- /dev/null +++ b/bwrap-files/workdir/entry.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euo pipefail + +cd "$(dirname "$0")" + +ghcup --offline run -- ghci Yahb2Defs.hs 2>&1 -- cgit v1.2.3-70-g09d2