summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-10-07 16:26:08 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-10-07 16:26:59 -0400
commit50eba52d7019620c9d4e1b4c4170bc8f93cf0af1 (patch)
tree50524f25625720121cf49b4f8d32ea3ded55171c /src
parent31a01dcbcb8509ce00e3f6b13cfb0210304d59d9 (diff)
librechroot: If stdout isn't a TTY, pipe progs in the chroot through cat.
Also, warn if stdin isn't a TTY.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/librechroot12
1 files changed, 11 insertions, 1 deletions
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" \