From 8850981d7362f95623b58d5af34343f1f8395eb6 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 13:42:06 -0400 Subject: ob-*: Add return statements after ob_error() calls --- (limited to 'src/ob-unpacksource.sh') diff --git a/src/ob-unpacksource.sh b/src/ob-unpacksource.sh index 76bb174..e90c6c0 100644 --- a/src/ob-unpacksource.sh +++ b/src/ob-unpacksource.sh @@ -29,7 +29,12 @@ upstream_ar_dir= unpack_native() { ob_info "$(ob_get_msg 'unpacking_native')" - cp -Rp '../src' 'src' || ob_error "$(ob_get_msg 'cant_unpack_native')" + if ! cp -Rp '../src' 'src'; then + ob_error "$(ob_get_msg 'cant_unpack_native')" + return 1 + fi + + return 0 } get_upstream_archive() @@ -43,6 +48,7 @@ get_upstream_archive() ;; *' '*) ob_error "$(ob_get_msg 'multiple_upstream_sources')" + return 1 ;; *) return 0 @@ -72,8 +78,11 @@ get_upstream_compression() *) ob_error "$(ob_get_msg 'unsupported_archive_compression')" \ "${z_ext}" + return 1 ;; esac + + return 0 } get_upstream_dir() @@ -87,28 +96,39 @@ get_upstream_dir() case "${dir_count}" in 0) ob_error "$(ob_get_msg 'no_upstream_dirs')" + return 1 ;; 1) ;; *) ob_error "$(ob_get_msg 'multiple_top_upstream_dirs')" + return 1 esac + + return 0 } extract_upstream() { ob_info "$(ob_get_msg 'unpacking_upstream')" - tar "-x${upstream_ar_z}f" "${upstream_ar}" || \ + if ! tar "-x${upstream_ar_z}f" "${upstream_ar}"; then ob_error "$(ob_get_msg 'cant_unpack_upstream')" - mv "${upstream_ar_dir}" 'src' || \ + return 1 + fi + if ! mv "${upstream_ar_dir}" 'src'; then ob_error "$(ob_get_msg 'cant_move_native')" + return 1 + fi + + return 0 } unpack_upstream() { - get_upstream_compression - get_upstream_dir - extract_upstream + get_upstream_compression || return 1 + get_upstream_dir || return 1 + extract_upstream || return 1 + return 0 } main() @@ -122,11 +142,13 @@ main() ob_info "$(ob_get_msg 'already_unpacked')" else if [ -d '../src' ]; then - unpack_native + unpack_native || return 1 elif get_upstream_archive; then - unpack_upstream + unpack_upstream || return 1 fi fi + + return 0 } main "${@}" -- cgit v0.9.1