Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 3ec57c4

Browse files
author
excalibur1234
committed
small speedup
1 parent 3c13d26 commit 3ec57c4

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pacui

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function func_m
332332

333333
echo " checking systemctl ..."
334334
# "LC_ALL=C" forces the output to use english language. this is important, if the output is queried.
335-
if [[ "$( LC_ALL=C systemctl --failed | head -n 1 | awk '{print $1}' )" == "UNIT" ]]
335+
if [[ "$( LC_ALL=C systemctl --failed | awk 'NR==1 {print $1}' )" == "UNIT" ]]
336336
then
337337
echo -e " \e[41m The following systemd service(s) have failed. Please fix them manually. \e[0m"
338338
echo -e " \e[1m Display detailed information about a systemd service with: systemctl status <SYSTEMD SERVICE NAME> \e[0m"
@@ -1132,22 +1132,24 @@ function func_b
11321132
then
11331133
# the while-loop here is needed to read the content of every line of $pacui_cache_install variable and save that line to variable $line.
11341134
pacui_aur_install="$(
1135-
while IFS='' read -r line || [[ -n "$line" ]]
1136-
do
1137-
## the problem here is that AUR packages are not named/numbered in a constant and easy sortable way. therefore, we search for all files and output their modification date in an easy searchable format (and then, the file name).
1138-
## then, "grep" is used to get only package files. then, the list is sorted (by the modification date).
1139-
## awk gets rid of the modification date. grep filters for the file name $line. sed only chooses the first/top line.
1140-
find "$cachePACAUR" -maxdepth 2 -mindepth 2 -type f -printf "%T+\t%p\n" | grep ".pkg.tar.[gx]z$" | sort -rn | awk '{print $2}' | grep "$line""-" | sed -n '1p'
1141-
done < <(echo "${pacui_cache_install}") )"
1135+
while IFS='' read -r line || [[ -n "$line" ]]
1136+
do
1137+
## the problem here is that AUR packages are not named/numbered in a constant and easy sortable way. therefore, we search for all files and output their modification date in an easy searchable format (and then, the file name).
1138+
## then, "grep" is used to get only package files. then, the list is sorted (by the modification date).
1139+
## awk gets rid of the modification date. grep filters for the file name $line. sed only chooses the first/top line.
1140+
find "$cachePACAUR" -maxdepth 2 -mindepth 2 -type f -printf "%T+\t%p\n" | grep ".pkg.tar.[gx]z$" | sort -rn | awk '{print $2}' | grep "$line""-" | sed -n '1p'
1141+
done < <(echo "${pacui_cache_install}")
1142+
)"
11421143
fi
11431144

11441145
# read line by line from variable $pacui_cache_install in while loop and save that line to variable $line
11451146
pacui_install="$(
1146-
while IFS='' read -r line || [[ -n "$line" ]]
1147-
do
1148-
# write name of latest version in cache into variable $pacui_install ("sort" puts latest version on top, which is then selected):
1149-
find "$cache" -name "${line}-[0-9a-z.-_]*.pkg.tar.[gx]z" | sort -r | sed -n '1p'
1150-
done < <(echo "${pacui_cache_install}") )"
1147+
while IFS='' read -r line || [[ -n "$line" ]]
1148+
do
1149+
# write name of latest version in cache into variable $pacui_install ("sort" puts latest version on top, which is then selected):
1150+
find "$cache" -name "${line}-[0-9a-z.-_]*.pkg.tar.[gx]z" | sort -r | sed -n '1p'
1151+
done < <(echo "${pacui_cache_install}")
1152+
)"
11511153

11521154
# sort output to suit pacman's syntax. pacman needs a list of package names separated by single spaces.
11531155
if [[ ! -z "$pacui_aur_install" ]]

0 commit comments

Comments
 (0)