From cddee020eb30a4aa8a72c0378103b810c8c1d8c7 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 18 Mar 2019 00:21:04 -0400 Subject: ob-installdocs: Declare local variables and wrap long lines --- diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index 9ea5b42..f07bfb8 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -21,29 +21,33 @@ set -eu install_docs() { - srcs="${1}" - dest="${2}" - data_doc_dir="${3}" + local srcs="${1}" + local dest="${2}" + local data_doc_dir="${3}" + shift 3 + local src= for src in ${srcs}; do if [ -f "${src}" ]; then - if ! mkdir -p -- "$(dirname -- "${data_doc_dir}/./${dest}")" - then + if ! mkdir -p -- "$(dirname -- \ + "${data_doc_dir}/./${dest}")"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi if ! cp -R -- "${src}" "${data_doc_dir}/${dest}"; then - ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" + ob_error "$(ob_get_msg 'cant_cp_doc_file')" \ + "${src}" return 1 fi elif [ -d "${src}" ]; then - if ! mkdir -p -- "$(dirname -- "${data_doc_dir}/./${dest}")" - then + if ! mkdir -p -- "$(dirname -- \ + "${data_doc_dir}/./${dest}")"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi if ! cp -R -- "${src}/." "${data_doc_dir}/${dest}"; then - ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" + ob_error "$(ob_get_msg 'cant_cp_doc_file')" \ + "${src}" return 1 fi fi @@ -54,6 +58,14 @@ install_docs() main() { + local doc_pkg= + local doc_pkg_doc_dir= + local pkg= + local doc_dir= + local data_doc_dir= + local srcs= + local dest= + if ! ob_set_text_domain 'opkbuild'; then printf '%s: Error: Failed to load locale messages\n' \ "${0##*/}" >&2 @@ -75,11 +87,14 @@ main() data_doc_dir="${pkg}.data/${doc_dir%/}" if [ x"${pkg}" = x"${doc_pkg}" ]; then if [ -d "${data_doc_dir}" ]; then - ob_info "$(ob_get_msg 'docs_already_installed')" "${pkg}" + ob_info "$(ob_get_msg \ + 'docs_already_installed')" "${pkg}" else - ob_info "$(ob_get_msg 'installing_docs')" "${pkg}" + ob_info "$(ob_get_msg 'installing_docs')" \ + "${pkg}" if ! mkdir -p -- "${data_doc_dir}"; then - ob_error "$(ob_get_msg 'cant_make_doc_dir')" + ob_error "$(ob_get_msg \ + 'cant_make_doc_dir')" return 1 fi while read srcs dest; do @@ -91,17 +106,20 @@ main() fi else if [ -L "${data_doc_dir}" ]; then - ob_info "$(ob_get_msg 'docs_already_linked')" "${pkg}" + ob_info "$(ob_get_msg 'docs_already_linked')" \ + "${pkg}" else ob_info "$(ob_get_msg 'linking_docs')" "${pkg}" if ! mkdir -p -- "$(dirname -- \ "${data_doc_dir}")"; then - ob_error "$(ob_get_msg 'cant_make_doc_dir')" + ob_error "$(ob_get_msg \ + 'cant_make_doc_dir')" return 1 fi if ! ln -s -- "${doc_pkg_doc_dir}" \ "${data_doc_dir}"; then - ob_error "$(ob_get_msg 'cant_ln_doc_dir')" + ob_error "$(ob_get_msg \ + 'cant_ln_doc_dir')" return 1 fi fi -- cgit v0.9.1