From 974ba342251703efe52849ebeda1627b187e8cb8 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Thu, 12 Dec 2024 08:23:14 +0100 Subject: [PATCH] chore: Use consistent syntax for getting information from os-release Please tell me if I escaped quotes correctly in `drivers.rs` --- process/drivers.rs | 2 +- scripts/exports.sh | 2 +- scripts/setup.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/process/drivers.rs b/process/drivers.rs index 0efa904d..49d6167f 100644 --- a/process/drivers.rs +++ b/process/drivers.rs @@ -282,7 +282,7 @@ fn get_version_run_image(oci_ref: &Reference) -> Result { .args(bon::vec![ "/bin/bash", "-c", - "grep -Po '(?<=VERSION_ID=)\\d+' /usr/lib/os-release", + r#"awk -F= '/^VERSION_ID=/ {gsub(/"/, "", $2); print $2}' /usr/lib/os-release"#, ]) .pull(true) .remove(true) diff --git a/scripts/exports.sh b/scripts/exports.sh index 3cae0768..a2332242 100644 --- a/scripts/exports.sh +++ b/scripts/exports.sh @@ -45,7 +45,7 @@ color_string() { } # Parse OS version and export it -export OS_VERSION="$(grep -Po "(?<=VERSION_ID=)\d+" /usr/lib/os-release)" +export OS_VERSION="$(awk -F= '/^VERSION_ID=/ {gsub(/"/, "", $2); print $2}' /usr/lib/os-release)" export OS_ARCH="$(uname -m)" # Export functions for use in sub-shells or sourced scripts diff --git a/scripts/setup.sh b/scripts/setup.sh index cc0d6316..5ba16754 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,7 +1,7 @@ #!/bin/sh if [ -f /etc/os-release ]; then - export ID="$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" + export ID="$(awk -F= '/^ID=/ {gsub(/"/, "", $2); print $2}' /etc/os-release)" if [ "$ID" = "alpine" ]; then echo "Setting up Alpine based image to run BlueBuild modules"