Skip to content

Commit

Permalink
chore: Optimize news path parsing when listing Arch news (#290)
Browse files Browse the repository at this point in the history
The command historically used for news path parsing was chaining multiple 'sed' calls in an unoptimized way. Everything is now merged into a single 'sed' call.
  • Loading branch information
Antiz96 authored Dec 20, 2024
1 parent 336bb90 commit 4b2f6c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/list_news.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else
if [ "${num}" -le "${news_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then
printed_news="true"
news_selected=$(sed -n "${num}"p <<< "${news_titles}")
news_path=$(echo "${news_selected}" | sed s/\ -//g | sed s/\ /-/g | sed s/[.]//g | sed s/=//g | sed s/\>//g | sed s/\<//g | sed s/\`//g | sed s/://g | sed s/+//g | sed s/[[]//g | sed s/]//g | sed s/,//g | sed s/\(//g | sed s/\)//g | sed s/[/]//g | sed s/@//g | sed s/\'//g | sed s/--/-/g | awk '{print tolower($0)}')
news_path=$(echo "${news_selected}" | sed -e s/\ -//g -e s/\ /-/g -e s/[.]//g -e s/=//g -e s/\>//g -e s/\<//g -e s/\`//g -e s/://g -e s/+//g -e s/[[]//g -e s/]//g -e s/,//g -e s/\(//g -e s/\)//g -e s/[/]//g -e s/@//g -e s/\'//g -e s/--/-/g | awk '{print tolower($0)}')
news_url="https://www.archlinux.org/news/${news_path}"
news_content=$(curl -m 30 -Lfs "${news_url}" || echo "error")

Expand Down

0 comments on commit 4b2f6c5

Please sign in to comment.