fix: parse OS_ID from /etc/os-release correctly on Rocky Linux 8.5 and similar distros - #328629
Open
0x5t4l1n wants to merge 1 commit into
Open
fix: parse OS_ID from /etc/os-release correctly on Rocky Linux 8.5 and similar distros#3286290x5t4l1n wants to merge 1 commit into
0x5t4l1n wants to merge 1 commit into
Conversation
Resolves microsoft#232159. The script used grep -Eo 'ID=([^"]+)' which requires the value to be unquoted. Rocky Linux 8.5 ships ID="rocky" (with double-quotes), so the grep matched nothing, OS_ID was empty, and the script exited with code 1 preventing devcontainer setup. Fix: replace the ad-hoc grep/sed pipeline with `source /etc/os-release` in a subshell. The shell assignment strips surrounding quotes and handles all conformant /etc/os-release formats as specified by man os-release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n\nFixes #232159 —
check-requirements-linux.shusedgrep -Eo 'ID=([^\"]+)'to parseOS_IDfrom/etc/os-release. This pattern only matches unquoted values (ID=rocky). Rocky Linux 8.5 shipsID=\"rocky\"(with surrounding double-quotes), which the grep did not match, leavingOS_IDempty. The script then exited with code 1, aborting devcontainer setup.\n\nFix: Replace the ad-hocgrep | sedpipeline with. /etc/os-release && echo \"${ID:-}\"in a subshell. POSIXsource(. file) correctly handles all value formats defined by theos-releasespec — quoted, unquoted, and escaped.\n\ndiff\n-OS_ID=\"$(cat /etc/os-release | grep -Eo 'ID=([^\"]+)' | sed -n '1s/ID=//p')\"\n+OS_ID=\"$(. /etc/os-release && echo \"${ID:-}\")\"\n\n\n## Test plan\n- [ ] Rocky Linux 8.5 container: devcontainer setup completes without exit code 1\n- [ ] Ubuntu / Debian / Alpine:OS_IDstill resolves correctly\n- [ ] NixOS: early exit still triggers\n- [ ]/etc/os-releaseabsent:OS_IDis empty (unchanged behaviour)\n\n🤖 Generated with Claude Code