summaryrefslogtreecommitdiffstats
path: root/lib/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cmd')
-rw-r--r--lib/cmd/shell.sh20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh
index 2745f4b..5c85d7e 100644
--- a/lib/cmd/shell.sh
+++ b/lib/cmd/shell.sh
@@ -24,6 +24,7 @@ use chroot
cmd_shell_main()
{
local root=
+ local uname_s=
if [ ${#} -lt 1 ]; then
print_cmd_usage 'shell' >&2
@@ -36,13 +37,28 @@ cmd_shell_main()
. "${root}/etc/os-release"
profile_set "${ID}"
+ uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown'
+ mkdir -p "${root}/prokit/wd/${$}"
+ case "${uname_s}" in
+ 'Linux')
+ mount -o bind . "${root}/prokit/wd/${$}"
+ ;;
+ esac
+
chroot_mount "${root}"
if [ ${#} -eq 0 ]; then
- chroot "${root}" /bin/sh
+ chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; /bin/sh"
printf '\n'
info "$(get_msg 'cmd_shell_exiting')"
else
- chroot "${root}" /bin/sh -c "${*}"
+ chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; ${*}"
fi
chroot_umount "${root}"
+
+ case "${uname_s}" in
+ 'Linux')
+ umount "${root}/prokit/wd/${$}"
+ ;;
+ esac
+ rmdir "${root}/prokit/wd/${$}"
}