particle-os-cli/templates/export.sh
fiftydinar 411e782dc8
fix: Remove trailing newlines from yaml arrays (#73)
Trailing newlines is something that we will never need as an
information, so it can only cause issues with parsing yaml values.

I scratched my head for 10 minutes on why my variable has a trailing
newline when I use `readarray -t` everywhere. Then I remembered
get_yaml_array function.

This should not affect current working modules at all, but it would be
good to test before landing.

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
2024-02-20 02:04:57 +00:00

8 lines
192 B
Bash

#!/usr/bin/env bash
get_yaml_array() {
readarray -t "$1" < <(echo "$3" | yq -I=0 "$2")
}
export -f get_yaml_array
export OS_VERSION=$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)