summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-09-01 17:22:49 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-09-01 17:22:49 (EDT)
commit9d1b9f98db96f1fc20e9acf106efd9559fdded6f (patch)
tree88647241d04d0c524b28d4e6a9ee5cb2e873d72a
parent5e41ca8a99db1788f549dff2ee307781f6bf3310 (diff)
cmd/shell: Accept command arguments
-rw-r--r--lib/cmd/shell.sh13
-rw-r--r--locale/en_US.sh2
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh
index 00589d2..2745f4b 100644
--- a/lib/cmd/shell.sh
+++ b/lib/cmd/shell.sh
@@ -25,19 +25,24 @@ cmd_shell_main()
{
local root=
- if [ ${#} -ne 1 ]; then
+ if [ ${#} -lt 1 ]; then
print_cmd_usage 'shell' >&2
exit 1
fi
root="${1}"
+ shift 1
. "${root}/etc/os-release"
profile_set "${ID}"
chroot_mount "${root}"
- chroot "${root}" /bin/sh
- printf '\n'
- info "$(get_msg 'cmd_shell_exiting')"
+ if [ ${#} -eq 0 ]; then
+ chroot "${root}" /bin/sh
+ printf '\n'
+ info "$(get_msg 'cmd_shell_exiting')"
+ else
+ chroot "${root}" /bin/sh -c "${*}"
+ fi
chroot_umount "${root}"
}
diff --git a/locale/en_US.sh b/locale/en_US.sh
index b8024ad..06f3250 100644
--- a/locale/en_US.sh
+++ b/locale/en_US.sh
@@ -87,7 +87,7 @@ msg_prokit_cmd_install_checksum_fail='Checksum of package file failed'
# lib/cmd/shell.sh
msg_prokit_cmd_shell_summary='run a shell in an isolated environment'
-msg_prokit_cmd_shell_usage='<root-dir>'
+msg_prokit_cmd_shell_usage='<root-dir> [<command> [<argument> ...]]'
msg_prokit_cmd_shell_exiting='Exiting...'
# lib/cmd/opkg.sh