From 24142a950a25d925e555ab31affef0b4c73f45c6 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 17:41:01 -0400 Subject: ob-installplatconf, ob-installdocs: Replace "${dest%/*}" checks with dirname --- (limited to 'src') diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index cf67383..e594610 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -29,22 +29,20 @@ install_docs() for src in ${srcs}; do if [ -f "${src}" ]; then - if [ x"${dest%/*}" != x"${dest}" ]; then - if ! mkdir -p "${data_doc_dir}/${dest%/*}"; then - ob_error "$(ob_get_msg 'cant_make_doc_dir')" - return 1 - fi + 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}" return 1 fi elif [ -d "${src}" ]; then - if [ x"${dest%/*}" != x"${dest}" ]; then - if ! mkdir -p "${data_doc_dir}/${dest%/*}"; then - ob_error "$(ob_get_msg 'cant_make_doc_dir')" - return 1 - fi + 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}" diff --git a/src/ob-installplatconf.sh b/src/ob-installplatconf.sh index c4a4765..d980ff8 100644 --- a/src/ob-installplatconf.sh +++ b/src/ob-installplatconf.sh @@ -28,6 +28,7 @@ copy_config() { list="${1}" dest_base="${2}" + dir= while read -r src dest; do if [ -z "${src}" ] || [ -z "${dest}" ]; then @@ -36,13 +37,11 @@ copy_config() fi # Make sure the destination directory exists. - if [ "x${dest%/*}" != "x${dest}" ]; then - if ! mkdir -p "${dest_base}/${dest%/*}"; then - ob_error "$(ob_get_msg \ - 'cant_make_config_dest_dir')" \ - "${dest%/*}" - return 1 - fi + dir="(dirname "${dest_base}/${dest}")" + if ! mkdir -p "${dir}"; then + ob_error "$(ob_get_msg 'cant_make_config_dest_dir')" \ + "${dir}" + return 1 fi # Find the config package files. -- cgit v0.9.1