diff --git a/Scripts/Modules/Locale/Modules/Directories/directories.sh b/Scripts/Modules/Locale/Modules/Directories/directories.sh index 05ff094..bccee93 100755 --- a/Scripts/Modules/Locale/Modules/Directories/directories.sh +++ b/Scripts/Modules/Locale/Modules/Directories/directories.sh @@ -33,7 +33,7 @@ function directories { # Sanitate non-option arguments to be sure they match the # directory conventions established by centos-art.sh script # against source directory locations in the working copy. - local DIRECTORY=$(tcar_checkWorkDirSource ${1}) + local DIRECTORY=$(tcar_printAbsolutePath ${1}) # Define regular expression used by locale module to determine the # file extension that it can retrieve translatable strings from, diff --git a/Scripts/Modules/Locale/Modules/Files/files.sh b/Scripts/Modules/Locale/Modules/Files/files.sh index c5dc2c9..f409476 100755 --- a/Scripts/Modules/Locale/Modules/Files/files.sh +++ b/Scripts/Modules/Locale/Modules/Files/files.sh @@ -28,7 +28,7 @@ function files { # Define absolute path of argument passed in the command-line. - local RENDER_FROM=$(tcar_checkWorkDirSource "${1}") + local RENDER_FROM=$(tcar_printAbsolutePath "${1}") # Verify the argument passed in the command-line is a regular # file. diff --git a/Scripts/Modules/Locale/locale.sh b/Scripts/Modules/Locale/locale.sh index 6fbcd8c..00aa962 100755 --- a/Scripts/Modules/Locale/locale.sh +++ b/Scripts/Modules/Locale/locale.sh @@ -61,7 +61,7 @@ function locale { # are files or directories. for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do - local ARGUMENT=$(tcar_checkWorkDirSource "${ARGUMENT}") + local ARGUMENT=$(tcar_printAbsolutePath "${ARGUMENT}") if [[ -f ${ARGUMENT} ]];then tcar_setModuleEnvironment -m "files" -t "child" -g "${ARGUMENT}" diff --git a/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh b/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh index 241d9bc..d8f37d5 100755 --- a/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh +++ b/Scripts/Modules/Prepare/prepare_setRenderEnvironment.sh @@ -91,7 +91,7 @@ function prepare_setRenderEnvironment { # Clean-up the search path. This location must point to a # directory inside the workplace. - DIRECTORY=$(tcar_checkWorkDirSource ${DIRECTORY}) + DIRECTORY=$(tcar_printAbsolutePath ${DIRECTORY}) # Verify the search path. It must exist and being a directory. tcar_checkFiles -ed ${DIRECTORY} diff --git a/Scripts/Modules/Render/Modules/Directories/directories.sh b/Scripts/Modules/Render/Modules/Directories/directories.sh index 3f22b1a..9db4469 100755 --- a/Scripts/Modules/Render/Modules/Directories/directories.sh +++ b/Scripts/Modules/Render/Modules/Directories/directories.sh @@ -27,7 +27,7 @@ # provided in the command-line points to a directory. function directories { - local DIRECTORY=$(tcar_checkWorkDirSource "${1}") + local DIRECTORY=$(tcar_printAbsolutePath "${1}") local CONFIGURATION_FILES=$(tcar_getFilesList -p '.+/.+\.conf$' -t 'f' ${DIRECTORY}) diff --git a/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh b/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh index 9bc2be8..f5ccaba 100755 --- a/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh +++ b/Scripts/Modules/Render/Modules/Files/Modules/Asciidoc/asciidoc_setXhtmlRendition.sh @@ -26,7 +26,7 @@ # Standardize the way docbook files are transformed in XHTML format. function asciidoc_setXhtmlRendition { - local LOCATION=$(tcar_checkWorkDirSource "${1}") + local LOCATION=$(tcar_printAbsolutePath "${1}") RENDER_PAGES=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-page") if [[ -z ${RENDER_PAGES} ]];then diff --git a/Scripts/Modules/Render/Modules/Files/files.sh b/Scripts/Modules/Render/Modules/Files/files.sh index 719f268..20764a8 100755 --- a/Scripts/Modules/Render/Modules/Files/files.sh +++ b/Scripts/Modules/Render/Modules/Files/files.sh @@ -28,7 +28,7 @@ # link. function files { - local CONFIGURATION=$(tcar_checkWorkDirSource "${1}") + local CONFIGURATION=$(tcar_printAbsolutePath "${1}") local -a SECTIONS local SECTION='' diff --git a/Scripts/Modules/Render/render.sh b/Scripts/Modules/Render/render.sh index d982069..472df94 100755 --- a/Scripts/Modules/Render/render.sh +++ b/Scripts/Modules/Render/render.sh @@ -40,7 +40,7 @@ function render { # Sanitate non-option arguments to be sure they match the # directory conventions established by tcar.sh script # against source directory locations in the working copy. - local ARGUMENT=$(tcar_checkWorkDirSource ${ARGUMENT}) + local ARGUMENT=$(tcar_printAbsolutePath ${ARGUMENT}) if [[ -d ${ARGUMENT} ]];then tcar_setModuleEnvironment -m 'directories' -t 'child' -g ${ARGUMENT} diff --git a/Scripts/Modules/Tuneup/tuneup.sh b/Scripts/Modules/Tuneup/tuneup.sh index 1117882..c0ae63d 100755 --- a/Scripts/Modules/Tuneup/tuneup.sh +++ b/Scripts/Modules/Tuneup/tuneup.sh @@ -36,7 +36,7 @@ function tuneup { # Sanitate non-option arguments to be sure they match the # directory conventions established by tcar.sh script # against source directory locations in the working copy. - local ARGUMENT=$(tcar_checkWorkDirSource ${ARGUMENT}) + local ARGUMENT=$(tcar_printAbsolutePath ${ARGUMENT}) # Build list of files to process. if [[ -f ${ARGUMENT} ]];then diff --git a/Scripts/tcar_checkWorkDirSource.sh b/Scripts/tcar_checkWorkDirSource.sh deleted file mode 100755 index 69f5c98..0000000 --- a/Scripts/tcar_checkWorkDirSource.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar - The CentOS Artwork Repository automation tool. -# Copyright © 2014 The CentOS Artwork SIG -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Alain Reguera Delgado -# 39 Street No. 4426 Cienfuegos, Cuba. -# -###################################################################### - -# Prepare non-option arguments passed through the command-line for -# further processing. When the argument provided is not an absolute -# path this function transforms it into an absolute path using the -# current working directory. -function tcar_checkWorkDirSource { - - local LOCATION=${1} - - # Append the current working directory when the location provided - # isn't absolute. - if [[ ! ${LOCATION} =~ '^/' ]];then - LOCATION=${PWD}/${LOCATION} - fi - - # Remove both consecutive slashes and trailing slashes from final - # location. Remove dot-slash, as well. - echo "${LOCATION}" | sed -r -e 's,/+,/,g' -e 's,/+$,,g' -e 's,\./,,g' - - # The single slash form doesn't point to repository's root - # directory anymore. Instead, when a single slash is passed - # as argument through the command-line, it preserves its regular - # meaning which is pointing the workstation's file system. - - # The path verification isn't appropriate here because this - # function is commonly used inside variable assignments and flow - # control doesn't take place in such situation. In case path - # verification fails here, the script wouldn't end its execution - # which contradicts the expected behaviour. - -} diff --git a/Scripts/tcar_printAbsolutePath.sh b/Scripts/tcar_printAbsolutePath.sh new file mode 100755 index 0000000..5a3f3c3 --- /dev/null +++ b/Scripts/tcar_printAbsolutePath.sh @@ -0,0 +1,38 @@ +#!/bin/bash +###################################################################### +# +# tcar - The CentOS Artwork Repository automation tool. +# Copyright © 2014 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Alain Reguera Delgado +# 39 Street No. 4426 Cienfuegos, Cuba. +# +###################################################################### + +# Print non-option arguments passed through the command-line for +# further processing. +function tcar_printAbsolutePath { + + local LOCATION=${1} + + if [[ ! ${LOCATION} =~ '^/' ]];then + LOCATION=${PWD}/${LOCATION} + fi + + tcar_printPath "${LOCATION}" + +}