Skip to content

Conversation

@Gullumluvl
Copy link
Contributor

Dear Discourse maintainers,

This is intended to fix an error I was getting with discourse-setup on Debian, from line 261:

bash: 12
scaling*                   2: syntax error in expression (error token is "scaling*                   2")

Caused by the parsing of lscpu command retaining 2 lines instead of just the intended one.

This occurs on my PCs with Debian testing (lscpu from util-linux 2.40.2) and Debian stable (util-linux 2.38.1) because it outputs a line formatted like this (in the "Vendor" section):

CPU(s) scaling MHz:                   20%

(I also checked on a machine with CentOS, there the format is CPU MHz: 2700.000).

To avoid that, I made the regex more specific, but I also added an exit statement in awk. Probably just one of these fixes could be used.

I believe the script would have worked with the version prior to this commit from a month ago: d00c2e7

Best,

@pfaffman
Copy link
Contributor

Maybe this is simpler:

lscpu -p|grep -v "#"|wc -l

Here's one AI recommended:

lscpu | sed -n 's/^CPU(s):\s*//p'

These both work inside of a Debian 12 container and Ubuntu 22.04

@Gullumluvl
Copy link
Contributor Author

lscpu -p|grep -v "#"|wc -l

This seems best to me, but we must double check with the people using ARM processors, as the commit I mentioned modified this almost exact same line.

Anything expected from me at this point? Sorry I have little experience with contributing to big projects so let me know.

@Gullumluvl Gullumluvl force-pushed the parse-cpu-count-only-one-line branch from 22e0e66 to df64418 Compare November 1, 2024 14:09
@Gullumluvl
Copy link
Contributor Author

Just rebased my branch on top of main, and amended the commit with a fix for localization.

@tgxworld tgxworld self-assigned this Nov 4, 2024
@tgxworld tgxworld merged commit 0b74eeb into discourse:main Dec 17, 2024
5 checks passed
@tgxworld
Copy link
Contributor

Thank you @Gullumluvl for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants