ditch echo
for printf
& redirect error messages to standard output stream
This commit is contained in:
parent
850ca56ff7
commit
14b734ad42
@ -27,7 +27,7 @@
|
||||
|
||||
# Check if we are in a git repo
|
||||
if ! git status >/dev/null; then
|
||||
echo "Not a git repo... exiting"
|
||||
printf "%s\n" "Not a git repo... exiting" >> /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -46,19 +46,20 @@ fi
|
||||
# This will likely exit firh error, because repoman
|
||||
# has to download some files (metadata.xsd)
|
||||
# We do that so we can truthfully test the actual latest commit
|
||||
echo ">>> Starting full test"
|
||||
echo "Running repoman -Idix"
|
||||
printf "%s\n" \
|
||||
">>> Starting full test" \
|
||||
"Running repoman -Idix"
|
||||
repoman -Idix
|
||||
echo "Running pkgcheck scan"
|
||||
printf "%s\n" "Running pkgcheck scan"
|
||||
pkgcheck scan
|
||||
|
||||
|
||||
echo ">>> Starting latest commit test"
|
||||
printf "%s\n" ">>> Starting latest commit test"
|
||||
|
||||
test_success=true
|
||||
|
||||
# Use pkgchek
|
||||
echo "Running pkgcheck scan --commits"
|
||||
printf "%s\n" "Running pkgcheck scan --commits"
|
||||
pkgcheck scan --commits || test_success=false
|
||||
|
||||
# Iterate through changed files in last commit
|
||||
@ -78,9 +79,9 @@ do
|
||||
|
||||
if cd "${commit_dir}"
|
||||
then
|
||||
echo
|
||||
echo "Directory $(pwd):"
|
||||
echo "Running repoman -Idix"
|
||||
printf "\n%s\n" \
|
||||
"Directory $(pwd):" \
|
||||
"Running repoman -Idix"
|
||||
repoman -Idix || test_success=false
|
||||
cd - >/dev/null || return
|
||||
fi
|
||||
@ -89,7 +90,7 @@ done
|
||||
# If any of the QA tools fail the test will fail
|
||||
if [ ${test_success} = false ]
|
||||
then
|
||||
echo ">>> Exiting with failure due to previous errors..."
|
||||
printf "%s\n" ">>> Exiting with failure due to previous errors..." >> /dev/stderr
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
|
@ -69,8 +69,12 @@ do
|
||||
done
|
||||
|
||||
# Output info with colors.
|
||||
echo -e "\e[1;33m${PACKAGE}\e[0m"
|
||||
echo -e " \e[1;35mPortage:\e[0m${PORTPACK_VERS}"
|
||||
echo -e " \e[1;35mOverlay:\e[0m${OVERPACK_VERS}"
|
||||
purple=$'\e[1;35m'
|
||||
esc=$'\e[0m'
|
||||
|
||||
printf "%s\n" \
|
||||
"${purple}${PACKAGE}${esc}" \
|
||||
" ${purple}Portage:${esc}${PORTPACK_VERS}" \
|
||||
" ${purple}Overlay:${esc}${OVERPACK_VERS}"
|
||||
fi
|
||||
done
|
||||
|
@ -46,11 +46,12 @@ reset="$(tput sgr0)"
|
||||
|
||||
|
||||
ok_msg() {
|
||||
echo "${bold}${green}* ${white}${1}${reset}"
|
||||
printf "%s\n" "${bold}${green}* ${white}${1}${reset}"
|
||||
}
|
||||
|
||||
err_msg() {
|
||||
echo "${bold}${red}* ${white}${1}${reset}"
|
||||
# redirect error messages to standard error stream
|
||||
printf "%s\n" "${bold}${red}* ${white}${1}${reset}" >> /dev/stderr
|
||||
}
|
||||
|
||||
usage() {
|
||||
@ -103,7 +104,7 @@ do
|
||||
if [ "${known_unique#*${pkg}}" = "${known_unique}" ]
|
||||
then
|
||||
nnuniq=$((nnuniq + 1))
|
||||
echo
|
||||
printf "\n"
|
||||
ok_msg "Package ${nnuniq} ${pkg}:"
|
||||
use_eix --exact --force-color "${pkg}"
|
||||
fi
|
||||
|
@ -36,5 +36,5 @@ then
|
||||
su root -c "rm -fr ${cache}" || exit 1
|
||||
fi
|
||||
else
|
||||
echo "No pre-generated md5-cache found in ${cache}"
|
||||
printf "%s\n" "No pre-generated md5-cache found in ${cache}" >> /dev/stderr
|
||||
fi
|
||||
|
@ -34,8 +34,9 @@ package="${package_directory%/}"
|
||||
|
||||
|
||||
error_no_version() {
|
||||
echo "[ERROR]: No version given"
|
||||
echo " Ran with option: ${1}"
|
||||
printf "%s\n" \
|
||||
"[ERROR]: No version given" \
|
||||
" Ran with option: ${1}" >> /dev/stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -45,11 +46,11 @@ git add .
|
||||
case "${1}"
|
||||
in
|
||||
"" )
|
||||
echo "[DEBUG]: no additional arguments/options given"
|
||||
printf "%s\n" "[DEBUG]: no additional arguments/options given" >> /dev/stderr
|
||||
repoman commit
|
||||
;;
|
||||
-b | --bump )
|
||||
echo "[DEBUG]: to be: ${package}: bump to ${2}"
|
||||
printf "%s\n" "[DEBUG]: to be: ${package}: bump to ${2}"
|
||||
if [ -n "${2}" ]
|
||||
then
|
||||
repoman commit -m "${package}: bump to ${2}"
|
||||
@ -58,7 +59,7 @@ in
|
||||
fi
|
||||
;;
|
||||
-d | --drop )
|
||||
echo "[DEBUG]: to be: ${package}: drop old ${2}"
|
||||
printf "%s\n" "[DEBUG]: to be: ${package}: drop old ${2}"
|
||||
if [ -n "${2}" ]
|
||||
then
|
||||
repoman commit -m "${package}: drop old ${2}"
|
||||
@ -67,11 +68,11 @@ in
|
||||
fi
|
||||
;;
|
||||
-* )
|
||||
echo "[ERROR]: Unknown option ${1}"
|
||||
printf "%s\n" "[ERROR]: Unknown option ${1}" >> /dev/stderr
|
||||
exit 1
|
||||
;;
|
||||
* )
|
||||
echo "[DEBUG]: to be: ${package}: ${*}"
|
||||
printf "%s\n" "[DEBUG]: to be: ${package}: ${*}"
|
||||
repoman commit -m "${package}: ${*}"
|
||||
;;
|
||||
esac
|
||||
|
@ -54,7 +54,7 @@ do
|
||||
# we want this to be privileged on Gentoo systems
|
||||
if [ "$(whoami)" != root ] && [ -z "${EPREFIX}" ]
|
||||
then
|
||||
echo "Switching to the root account"
|
||||
printf "%s\n" "Switching to the root account"
|
||||
su root -c "ebuild ${ebuild} clean test merge"
|
||||
else
|
||||
ebuild "${ebuild}" clean test merge
|
||||
|
@ -58,7 +58,7 @@ eprefix_addpath() {
|
||||
PATH=${1}:${PATH}
|
||||
export PATH
|
||||
else
|
||||
echo "${eprefix_warn} ${1} not found"
|
||||
printf "%s\n" "${eprefix_warn} ${1} not found" >> /dev/stderr
|
||||
fi
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ eprefix_addman() {
|
||||
MANPATH=${1}:${MANPATH}
|
||||
export MANPATH
|
||||
else
|
||||
echo "${eprefix_warn} ${1} not found"
|
||||
printf "%s\n" "${eprefix_warn} ${1} not found" >> /dev/stderr
|
||||
fi
|
||||
}
|
||||
|
||||
@ -95,9 +95,10 @@ case ${-} in
|
||||
:
|
||||
;;
|
||||
* )
|
||||
echo "${eprefix_bad} Error: not a login shell"
|
||||
echo "${eprefix_bad} Run: source ${0}"
|
||||
echo ">>> Exiting the shell"
|
||||
printf "%s\n" \
|
||||
"${eprefix_bad} Error: not a login shell" \
|
||||
"${eprefix_bad} Run: source ${0}" \
|
||||
">>> Exiting the shell" >> /dev/stderr
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@ -105,8 +106,9 @@ esac
|
||||
# Exit if eprefix does not exist
|
||||
if [ ! -d "${EPREFIX}" ]
|
||||
then
|
||||
echo "${eprefix_bad} No ${EPREFIX} found!"
|
||||
echo ">>> Exiting the shell"
|
||||
printf "%s\n" \
|
||||
"${eprefix_bad} No ${EPREFIX} found!" \
|
||||
">>> Exiting the shell" >> /dev/stderr
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
@ -178,44 +180,42 @@ FEATURES="${FEATURES} -usersandbox -sandbox"
|
||||
export FEATURES
|
||||
|
||||
# Check if we are on a prefix profile
|
||||
echo ""
|
||||
printf "\n"
|
||||
if command_exists eselect
|
||||
then
|
||||
eprofile="$(eselect profile show)"
|
||||
|
||||
if [[ "${eprofile}" == *prefix* ]]
|
||||
then
|
||||
echo "${eprefix_good} ${eprofile}"
|
||||
printf "%s\n" "${eprefix_good} ${eprofile}"
|
||||
else
|
||||
echo "${eprefix_bad} You are not on a prefix profile"
|
||||
printf "%s\n" "${eprefix_bad} You are not on a prefix profile" >> /dev/stderr
|
||||
fi
|
||||
|
||||
unset eprofile
|
||||
else
|
||||
echo "${eprefix_bad} Could not determine running profile"
|
||||
printf "%s\n" "${eprefix_bad} Could not determine running profile" >> /dev/stderr
|
||||
fi
|
||||
|
||||
|
||||
# >>> Finish
|
||||
|
||||
echo ""
|
||||
echo ">>> Sourced the eprefix script"
|
||||
echo ""
|
||||
echo "${eprefix_good} Prefix: ${EPREFIX}"
|
||||
echo "${eprefix_good} Packages: $(eprefix_packages)"
|
||||
echo "${eprefix_good} In World: $(eprefix_world)"
|
||||
echo "${eprefix_good} Have fun! ;-)"
|
||||
printf "\n%s\n" \
|
||||
">>> Sourced the eprefix script\n" \
|
||||
"${eprefix_good} Prefix: ${EPREFIX}" \
|
||||
"${eprefix_good} Packages: $(eprefix_packages)" \
|
||||
"${eprefix_good} In World: $(eprefix_world)" \
|
||||
"${eprefix_good} Have fun! ;-)"
|
||||
|
||||
|
||||
if command_exists emerge
|
||||
then
|
||||
echo ""
|
||||
echo ">>> Environment ready"
|
||||
printf "\n%s\n" ">>> Environment ready"
|
||||
else
|
||||
echo ""
|
||||
echo "${eprefix_bad} Could not locate emerge"
|
||||
echo "${eprefix_bad} Environment may be broken"
|
||||
echo ">>> Continuing anyway..."
|
||||
printf "\n%s\n" \
|
||||
"${eprefix_bad} Could not locate emerge" \
|
||||
"${eprefix_bad} Environment may be broken" \
|
||||
">>> Continuing anyway..." >> /dev/stderr
|
||||
fi
|
||||
|
||||
|
||||
|
@ -31,9 +31,10 @@ export PATH
|
||||
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "No overlay names given"
|
||||
echo "Please give at least one overlay name as a commandline argument"
|
||||
echo "Exiting"
|
||||
printf "%s\n" \
|
||||
"No overlay names given" \
|
||||
"Please give at least one overlay name as a commandline argument" \
|
||||
"Exiting" >> /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -43,5 +44,5 @@ do
|
||||
do
|
||||
euscan --nocolor --quiet "${ebuild}" | tee -a "euscan-${overlay}.log"
|
||||
done
|
||||
echo ">>> Done scanning ${overlay}"
|
||||
printf "%s\n" ">>> Done scanning ${overlay}"
|
||||
done
|
||||
|
@ -21,8 +21,8 @@
|
||||
function scanning(){
|
||||
EUSCAN=$(euscan --nocolor --quiet "$1")
|
||||
if [ -n "$EUSCAN" ]; then
|
||||
echo "=============== NOW: $(find ./* -mindepth 2 -maxdepth 2 -name ''"$1"'*.ebuild' | tail -1) =================
|
||||
$(echo -e "$EUSCAN" | tail -1)"
|
||||
printf "%s\n" "=============== NOW: $(find ./* -mindepth 2 -maxdepth 2 -name ''"$1"'*.ebuild' | tail -1) =================
|
||||
$(printf "%s\n" "$EUSCAN" | tail -1)"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ function folder(){
|
||||
|
||||
for FILE in */*
|
||||
do
|
||||
PACKAGE=$(echo "$FILE" | grep -Eo '[A-z0-9_-]+$')
|
||||
PACKAGE=$(printf "%s\n" "$FILE" | grep -Eo '[A-z0-9_-]+$')
|
||||
PACKAGES+=("$PACKAGE")
|
||||
done
|
||||
|
||||
@ -47,14 +47,15 @@ function folder(){
|
||||
wait "$j"
|
||||
done
|
||||
|
||||
echo -n ">>> Done scanning $1"
|
||||
printf "%s\n" ">>> Done scanning $1"
|
||||
}
|
||||
|
||||
function nofolder(){
|
||||
if [ -z "${1}" ]; then
|
||||
echo "No overlay names given"
|
||||
echo "Please give at least one overlay name as a commandline argument"
|
||||
echo "Exiting"
|
||||
printf "%s\n" \
|
||||
"No overlay names given" \
|
||||
"Please give at least one overlay name as a commandline argument" \
|
||||
"Exiting" >> /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -70,23 +71,23 @@ do
|
||||
wait "$j"
|
||||
done
|
||||
|
||||
echo -n ">>> Done scanning ${overlay}"
|
||||
printf "%s\n" ">>> Done scanning ${overlay}"
|
||||
done
|
||||
}
|
||||
|
||||
function help(){
|
||||
echo "You can use:"
|
||||
echo "* -r or --repo <HERE-REPO-NAME>"
|
||||
echo "* -f or --folder <FOLDER-NAME>"
|
||||
echo
|
||||
echo "Example of usage"
|
||||
echo "./euscan-parallel -r src_prepare-overlay"
|
||||
echo "./euscan-parallel -f ~/git/src_prepare-overlay"
|
||||
printf "%s\n" \
|
||||
"You can use:" \
|
||||
"* -r or --repo <HERE-REPO-NAME>" \
|
||||
"* -f or --folder <FOLDER-NAME>\n" \
|
||||
"Example of usage" \
|
||||
"./euscan-parallel -r src_prepare-overlay" \
|
||||
"./euscan-parallel -f ~/git/src_prepare-overlay"
|
||||
}
|
||||
|
||||
function main(){
|
||||
[ "$(whereis eix | wc -w)" -le "1" ] && { echo "The eix is NOT installed"; exit; }
|
||||
[ "$(whereis euscan | wc -w)" -le "1" ] && { echo "The euscan is NOT installed"; exit; }
|
||||
[ "$(whereis eix | wc -w)" -le "1" ] && { printf "%s\n" "The eix is NOT installed" >> /dev/stderr; exit; }
|
||||
[ "$(whereis euscan | wc -w)" -le "1" ] && { printf "%s\n" "The euscan is NOT installed" >> /dev/stderr; exit; }
|
||||
case $1 in
|
||||
-h|--help)
|
||||
help
|
||||
@ -98,7 +99,7 @@ function main(){
|
||||
folder "$2" | tee -a "euscan-$(date -I).log"
|
||||
;;
|
||||
*)
|
||||
echo "No found variable"; echo; help
|
||||
printf "%s\n" "No found variable" >> /dev/stderr; printf "\n"; help
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ export PATH
|
||||
|
||||
|
||||
emsg() {
|
||||
echo "$(tput bold)$(tput setaf 6)>>> $(tput setaf 4)$(date +%H:%M:%S)$(tput setaf 7) ${*} $(tput sgr0)"
|
||||
printf "%s\n" "$(tput bold)$(tput setaf 6)>>> $(tput setaf 4)$(date +%H:%M:%S)$(tput setaf 7) ${*} $(tput sgr0)"
|
||||
}
|
||||
|
||||
edie() {
|
||||
|
@ -74,15 +74,15 @@ main() {
|
||||
ebuild="$(basename "$(pwd)")-9999.ebuild"
|
||||
if [ ! -f "${ebuild}" ]
|
||||
then
|
||||
echo "${ebuild_template}" > "${ebuild}"
|
||||
printf "%s\n" "${ebuild_template}" > "${ebuild}"
|
||||
else
|
||||
echo "Already exists: ${ebuild}"
|
||||
printf "%s\n" "Already exists: ${ebuild}" >> /dev/stderr
|
||||
fi
|
||||
if [ ! -f "metadata.xml" ]
|
||||
then
|
||||
echo "${metadata_template}" > "metadata.xml"
|
||||
printf "%s\n" "${metadata_template}" > "metadata.xml"
|
||||
else
|
||||
echo "Already exists: metadata.xml"
|
||||
printf "%s\n" "Already exists: metadata.xml" >> /dev/stderr
|
||||
fi
|
||||
}
|
||||
|
||||
@ -91,10 +91,11 @@ if [ -f ../../profiles/repo_name ]
|
||||
then
|
||||
main
|
||||
else
|
||||
echo "Are you in a overlay repo?"
|
||||
echo "To use this script successfully:"
|
||||
echo "1. Create a \${CATEGOTY}/\${PN} directory"
|
||||
echo "2. Change directory to it"
|
||||
echo "3. Execute ${0}"
|
||||
printf "%s\n" \
|
||||
"Are you in a overlay repo?" \
|
||||
"To use this script successfully:" \
|
||||
"1. Create a \${CATEGOTY}/\${PN} directory" \
|
||||
"2. Change directory to it" \
|
||||
"3. Execute ${0}" >> /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
2
src/pn
2
src/pn
@ -26,4 +26,4 @@ trap 'exit 128' INT
|
||||
cd "${1:-$(pwd)}" || exit 1
|
||||
|
||||
path="$(git rev-parse --show-prefix)"
|
||||
echo "${path%/}"
|
||||
printf "%s\n" "${path%/}"
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Must specify a file to modify..."
|
||||
printf "%s\n" "Must specify a file to modify..."
|
||||
exit 1
|
||||
fi
|
||||
regex='^=?(\S+)(?:-[[:digit:]]+\S*)(\s)(\S+)$'
|
||||
|
@ -36,12 +36,13 @@ main() {
|
||||
case ${1}
|
||||
in
|
||||
-h | -help | --help )
|
||||
echo "Usage: ${0}"
|
||||
echo "Performed in this script:"
|
||||
echo "1. remove Manifest file"
|
||||
echo "2. regen Manifest with 'repoman manifest'"
|
||||
echo "3. Check with 'repoman -Idx full'"
|
||||
echo "4. Check with 'pkgcheck scan'"
|
||||
printf "%s\n" \
|
||||
"Usage: ${0}" \
|
||||
"Performed in this script:" \
|
||||
"1. remove Manifest file" \
|
||||
"2. regen Manifest with 'repoman manifest'" \
|
||||
"3. Check with 'repoman -Idx full'" \
|
||||
"4. Check with 'pkgcheck scan'"
|
||||
;;
|
||||
* )
|
||||
main
|
||||
|
@ -48,12 +48,13 @@ ignored_dirs=(
|
||||
# This will likely exit firh error, because repoman
|
||||
# has to download some files (metadata.xsd)
|
||||
# We do that so we can truthfully test the actual latest commit
|
||||
echo ">>> Starting full test"
|
||||
echo "Running repoman -Idix"
|
||||
printf "%s\n" \
|
||||
">>> Starting full test" \
|
||||
"Running repoman -Idix"
|
||||
repoman -Idix
|
||||
|
||||
|
||||
echo ">>> Starting latest commit test"
|
||||
printf "%s\n" ">>> Starting latest commit test"
|
||||
|
||||
# If any of the QA checks fail the test will fail
|
||||
test_success=true
|
||||
@ -70,17 +71,16 @@ do
|
||||
do
|
||||
if [[ "${commit_dir}" = *"${i_dir}"* ]]
|
||||
then
|
||||
echo
|
||||
echo "Ignoring ${commit_dir}"
|
||||
printf "\n%s\n" "Ignoring ${commit_dir}"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
if cd "${commit_dir}"
|
||||
then
|
||||
echo
|
||||
echo "Checking ${commit_dir}"
|
||||
echo "Running repoman -Idix"
|
||||
printf "\n%s\n" \
|
||||
"Checking ${commit_dir}" \
|
||||
"Running repoman -Idix"
|
||||
repoman -Idix || test_success="false"
|
||||
cd - >/dev/null || return
|
||||
fi
|
||||
@ -88,9 +88,9 @@ done
|
||||
|
||||
if [ "${test_success}" = "false" ]
|
||||
then
|
||||
echo ">>> Exiting with failure due to previous errors"
|
||||
printf "%s\n" ">>> Exiting with failure due to previous errors" >> /dev/stderr
|
||||
exit 1
|
||||
else
|
||||
echo ">>> Exiting successfully"
|
||||
printf "%s\n" ">>> Exiting successfully"
|
||||
exit 0
|
||||
fi
|
||||
|
15
test.sh
15
test.sh
@ -30,16 +30,15 @@ exit_result=0
|
||||
run_test() {
|
||||
for file in ${2}
|
||||
do
|
||||
echo "File ${file}... checking"
|
||||
printf "%s\n" "File ${file}... checking"
|
||||
if command "${1}" "${file}"
|
||||
then
|
||||
echo " file is correct"
|
||||
printf "%s\n" " file is correct"
|
||||
else
|
||||
echo " there were errors found in the file"
|
||||
printf "%s\n" " there were errors found in the file" >> /dev/stderr
|
||||
exit_result=1
|
||||
fi
|
||||
echo "Done: ${file}"
|
||||
echo
|
||||
printf "%s\n\n" "Done: ${file}"
|
||||
done
|
||||
}
|
||||
|
||||
@ -52,11 +51,9 @@ run_test pylint "${py_files}"
|
||||
|
||||
if [ ${exit_result} = 0 ]
|
||||
then
|
||||
echo "No errors reported"
|
||||
echo "Exiting successfully"
|
||||
printf "%s\n" "No errors reported" "Exiting successfully"
|
||||
exit ${exit_result}
|
||||
else
|
||||
echo "Some errors reported"
|
||||
echo "Exiting without success"
|
||||
printf "%s\n" "Some errors reported" "Exiting without success" >> /dev/stderr
|
||||
exit ${exit_result}
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user