diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-01-17 16:10:31 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-01-17 16:10:31 (EST) |
commit | 09c583248e7c0aa5a833ec01262b8b4a7980234b (patch) | |
tree | e3ecd4028e888d6eb587d9703ace4d90396a624a /src/cmd/shell.sh | |
parent | d5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff) | |
parent | e3ab87a78aafd979f6eb8bb75ef70304d87a1d6b (diff) |
Merge branch 'feature/improve-error-handling'
Diffstat (limited to 'src/cmd/shell.sh')
-rw-r--r-- | src/cmd/shell.sh | 18 |
1 files changed, 14 insertions, 4 deletions
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() |