Skip to content

Conversation

@craigds
Copy link
Contributor

@craigds craigds commented Oct 23, 2025

In AlmaLinux, the ID in /etc/os-release is quoted

$ docker run -it --rm almalinux:9 cat /etc/os-release | grep ^ID= 2>/dev/null
ID="almalinux"

In AlmaLinux, the ID in /etc/os-release is quoted

```
$ docker run -it --rm almalinux:9 cat /etc/os-release | grep ^ID= 2>/dev/null
ID="almalinux"
```
try {
const osRelease = await fs.promises.readFile("/etc/os-release")
const match = osRelease.toString().match(/^ID=(.*)$/m)
const match = osRelease.toString().match(/^ID="?(.*?)"?$/m)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be slightly more robust to do this instead:

-    return match ? match[1] : "(unknown)"
+    return match ? match[1].replace(/^"(.*)"$/, "$1") : "(unknown)"

But this is good enough, I think, there is little chance that /etc/os-release contains an unmatched quote at the start or end.

@dscho dscho merged commit 9330690 into mxschmitt:master Oct 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants