Skip to content

fix(server): handle quoted ID values in /etc/os-release#308001

Open
tysoncung wants to merge 1 commit intomicrosoft:mainfrom
tysoncung:fix/232159-rocky-os-release
Open

fix(server): handle quoted ID values in /etc/os-release#308001
tysoncung wants to merge 1 commit intomicrosoft:mainfrom
tysoncung:fix/232159-rocky-os-release

Conversation

@tysoncung
Copy link
Copy Markdown

Problem

The devcontainer setup script check-requirements-linux.sh fails to parse /etc/os-release on Rocky Linux 8.5 because it uses ad-hoc grep/sed parsing that doesn't handle quoted values.

On Rocky 8.5, the file contains:

ID="rocky"

The current regex pattern ID=([^"]+) fails to match this format, causing OS_ID to be empty and the script to exit with code 1.

Solution

Replace the ad-hoc parsing with proper shell variable sourcing:

OS_ID=$(source /etc/os-release && echo $ID)

This approach:

  • ✅ Handles both quoted and unquoted values correctly
  • ✅ Runs in a subshell to prevent environment pollution
  • ✅ Follows the official /etc/os-release spec (shell-style variable assignments)
  • ✅ More robust and maintainable

Files Changed

  • resources/server/bin/helpers/check-requirements-linux.sh

Closes #232159

…2159)

- Replace ad-hoc grep/sed parsing with proper source command
- Fixes parsing failure on Rocky Linux 8.5 where ID="rocky"
- Subshell isolation prevents environment pollution
- More robust handling of shell-style variable assignments

Closes microsoft#232159
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.

Devcontainer setup ad-hoc parsing fails on Rocky 8.5

2 participants