summaryrefslogtreecommitdiff
path: root/src/chroot-tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools')
-rwxr-xr-xsrc/chroot-tools/indent4
-rwxr-xr-xsrc/chroot-tools/librechroot14
2 files changed, 16 insertions, 2 deletions
diff --git a/src/chroot-tools/indent b/src/chroot-tools/indent
index 5a7f654..0e2d0e0 100755
--- a/src/chroot-tools/indent
+++ b/src/chroot-tools/indent
@@ -19,7 +19,9 @@ while (1) {
$c = substr($buffer, $_, 1);
if ($c eq "\n") {
syswrite(STDOUT, $indent) if ($print_indent);
- syswrite(STDOUT, $c, 1);
+ # XXX: SYSTEMD-STDOUT HACK
+ #syswrite(STDOUT, $c, 1);
+ syswrite(STDOUT, "\r\n", 2);
$print_indent = 1;
} elsif ($c eq "\r") {
syswrite(STDOUT, $c, 1);
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 4941b95..65977ea 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -178,10 +178,22 @@ arch_nspawn_flags=()
sysd_nspawn_flags=()
arch-nspawn() {
local copydir=$1; shift
+ # XXX: SYSTEMD-STDOUT HACK
if [[ -t 1 ]]; then
cmd=("$@")
else
- cmd=(bash --noprofile --norc -c "set -o pipefail; $(printf '%q ' "$@") |&cat")
+ # This perl script is equivalent to `sed -s 's|\n|\r\n|g', but
+ # it doesn't line-buffer.
+ local perlcmd='
+my $size;
+my $buffer;
+while(1) {
+ $size=sysread(STDIN, $buffer, 40);
+ last if ($size < 1);
+ $buffer =~ s/\n/\r\n/g;
+ syswrite(STDOUT, $buffer);
+}'
+ cmd=(bash --noprofile --norc -c "set -o pipefail; $(printf '%q ' "$@") |& perl -e $(printf '%q' "$perlcmd")")
fi
set +u # if an array is empty, it counts as unbound