From 09c583248e7c0aa5a833ec01262b8b4a7980234b Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 17 Jan 2016 16:10:31 -0500 Subject: Merge branch 'feature/improve-error-handling' --- (limited to 'src/cmd/shell.sh') diff --git a/src/cmd/shell.sh b/src/cmd/shell.sh index e761f55..8d5cd16 100644 --- a/src/cmd/shell.sh +++ b/src/cmd/shell.sh @@ -25,7 +25,7 @@ cmd_shell_main() if [ ${#} -lt 1 ]; then print_cmd_usage 'shell' >&2 - exit 1 + return 1 fi root="${1}" @@ -34,12 +34,20 @@ cmd_shell_main() dev='' if is_block "${root}"; then dev="${root}" - root="$(block_mount "${dev}")" + if ! root="$(block_mount "${dev}")"; then + return 2 + fi fi - profile_detect "${root}" + if ! profile_detect "${root}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi - session_begin "${root}" . : false + if ! session_begin "${root}" . : false; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi if [ ${#} -eq 0 ]; then session_exec /bin/sh printf '\n' @@ -50,6 +58,8 @@ cmd_shell_main() session_end [ "x${dev}" != 'x' ] && block_umount "${root}" + + return 0 } cmd_shell_register() -- cgit v0.9.1