Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/process_substitution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree 2>/dev/null || echo "${0%/*}")}"
TRY="$TRY_TOP/try"

cleanup() {
cd /

if [ -d "$try_workspace" ]
then
rm -rf "$try_workspace" >/dev/null 2>&1
fi
}

trap 'cleanup' EXIT

if ! command -v bash >/dev/null 2>&1
then
exit 0
fi

try_workspace="$(mktemp -d)"
cd "$try_workspace" || exit 9

TRY_SHELL="$(command -v bash)" \
"$TRY" -n 'diff <(printf "alpha\n") <(printf "alpha\n")' || exit 1
32 changes: 32 additions & 0 deletions test/process_substitution_D_flag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree 2>/dev/null || echo "${0%/*}")}"
TRY="$TRY_TOP/try"

cleanup() {
cd /

if [ -d "$try_workspace" ]
then
rm -rf "$try_workspace" >/dev/null 2>&1
fi

if [ -d "$try_sandbox" ]
then
rm -rf "$try_sandbox" >/dev/null 2>&1
fi
}

trap 'cleanup' EXIT

if ! command -v bash >/dev/null 2>&1
then
exit 0
fi

try_workspace="$(mktemp -d)"
try_sandbox="$(mktemp -d)"
cd "$try_workspace" || exit 9

TRY_SHELL="$(command -v bash)" \
"$TRY" -D "$try_sandbox" 'diff <(printf "alpha\n") <(printf "alpha\n")' || exit 1
6 changes: 6 additions & 0 deletions try
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ devices_to_mount="tty null zero full random urandom"
## Mounts and unmounts a few select devices instead of the whole `/dev`
mount_devices() {
sandbox_dir="$1"
mkdir -p "$sandbox_dir/temproot/dev" "$sandbox_dir/temproot/dev/pts"
for dev in $devices_to_mount
do
touch "$sandbox_dir/temproot/dev/$dev"
Expand Down Expand Up @@ -272,6 +273,8 @@ exitcode="$?"
rm "$sandbox_dir/temproot/dev/stdin"
rm "$sandbox_dir/temproot/dev/stdout"
rm "$sandbox_dir/temproot/dev/stderr"
rm "$sandbox_dir/temproot/dev/fd"
rm "$sandbox_dir/temproot/dev/ptmx"

unmount_devices "$SANDBOX_DIR"

Expand All @@ -285,7 +288,10 @@ EOF
unset START_DIR SANDBOX_DIR UNION_HELPER DIRS_AND_MOUNTS TRY_EXIT_STATUS TRY_COMMAND TRY_SHELL UPDATED_DIRS_AND_MOUNTS
unset script_to_execute chroot_executable try_mount_log

mount -t devpts devpts /dev/pts -o newinstance,ptmxmode=0666,mode=0620,gid=$(getent group tty | cut -d: -f3 || echo 5) 2>/dev/null &&
[ -e /dev/ptmx ] || ln -s /dev/pts/ptmx /dev/ptmx &&
mount -t proc proc /proc &&
ln -s /proc/self/fd /dev/fd &&
ln -s /proc/self/fd/0 /dev/stdin &&
ln -s /proc/self/fd/1 /dev/stdout &&
ln -s /proc/self/fd/2 /dev/stderr &&
Expand Down