From 50eba52d7019620c9d4e1b4c4170bc8f93cf0af1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 7 Oct 2013 16:26:08 -0400 Subject: librechroot: If stdout isn't a TTY, pipe progs in the chroot through cat. Also, warn if stdin isn't a TTY. --- src/chroot-tools/librechroot | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/chroot-tools/librechroot') diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index bebc46f..81163b0 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -178,8 +178,14 @@ arch_nspawn_flags=() sysd_nspawn_flags=() arch-nspawn() { local copydir=$1; shift + if [[ -t 1 ]]; then + cmd=("$@") + else + cmd=(bash --noprofile --norc -c "$(printf '%q ' "$@") |&cat") + fi + set +u # if an array is empty, it counts as unbound - "$_arch_nspawn" "${arch_nspawn_flags[@]}" "$copydir" "${sysd_nspawn_flags[@]}" -- "$@" + "$_arch_nspawn" "${arch_nspawn_flags[@]}" "$copydir" "${sysd_nspawn_flags[@]}" -- "${cmd[@]}" set -u } @@ -236,6 +242,10 @@ main() { umask 0022 + if ! [[ -t 0 ]]; then + warning "Input is not a TTY--signals will not be handled correctly." + fi + # Keep this lock as long as we are running # Note that '9' is the same FD number as in mkarchroot et al. lock 9 "$copydir.lock" \ -- cgit v1.2.2