#!/bin/bash

set -x

path_add=""
if [[ "$VISUAL" != "" ]] ; then
    vis="--setenv VISUAL ""$VISUAL"
fi
if [[ "$EDITOR" != "" ]] ; then
    edit="--setenv EDITOR ""$EDITOR"
fi

for i in $(echo $PATH | sed -r 's/:/\n/g') ; do
    path_add="$path_add --ro-bind $i $i"
done

bwrap \
--unshare-all \
--share-net \
--die-with-parent \
--ro-bind /usr /usr \
--ro-bind /bin /bin \
--ro-bind /lib /lib \
--ro-bind /lib64 /lib64 \
--proc /proc \
--dev /dev \
--tmpfs /tmp \
--dir /home \
--bind "$PWD" "$PWD" \
--setenv PATH "$PATH" \
$vis $edit \
--ro-bind /etc/ld.so.cache /etc/ld.so.cache\
$path_add \
-- drharness "$@"
