ditch echo for printf & redirect error messages to standard output stream

This commit is contained in:
xosefulk
2021-06-04 14:19:26 +06:00
parent 850ca56ff7
commit 14b734ad42
16 changed files with 116 additions and 108 deletions

View File

@ -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
}