From 3566cf0a8d9c5df323c87d94d8ed1d3dddc3a57c Mon Sep 17 00:00:00 2001 From: brian-level <98054876+brian-level@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:30:11 -0400 Subject: [PATCH] Use regular (not Perl) grep syntax in scripts (#887) Mac platforms are become more locked-down and when grep is installed by XCode for example it is a BSD version not GNU version so doesn't have the "-P" option to use perl patterns. This fixes scripts to not depend on GNU grep. --- script/generate | 8 ++++++-- script/util | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/script/generate b/script/generate index d1cef59a..606e4c94 100755 --- a/script/generate +++ b/script/generate @@ -117,7 +117,9 @@ trust_sdk_and_extensions() # Parse extension name local extension_name="" - extension_name=$(grep -oP '^id: \K(.*)' "${slce_file}") + extension_line=$(grep -m 1 'id: ' "${slce_file}") + extension_name="${extension_line//id:/}" + extension_name="${extension_name// /}" # Define symlink location local extension_symlink="${sdk_dir}/extension/${extension_name}" @@ -174,7 +176,9 @@ generate() # Define generation variables local slcp=${1?A .slcp file is expected as the first argument} local project_name="" - project_name=$(grep -oP 'project_name: \K(.*)' "${slcp}") + project_line=$(grep 'project_name: ' "${slcp}") + project_name="${project_line//project_name:/}" + project_name="${project_name// /}" local generation_dir=${2?A generation output dir is expected as the second argument} local export_templates="${repo_dir}/slc/exporter_templates/platform_library" local board=${3?A board is expected as the third argument} diff --git a/script/util b/script/util index bd21282c..5e8c75fb 100644 --- a/script/util +++ b/script/util @@ -85,10 +85,20 @@ parse_configuration() old_setting=${-//[^e]/} set +e # grep raw values from the configuration file - rcp_uart_slcp="$(grep -oP 'rcp_uart_slcp: \K(.*)' "${config_yml}")" - rcp_spi_slcp="$(grep -oP 'rcp_spi_slcp: \K(.*)' "${config_yml}")" - soc_slcp="$(grep -oP 'soc_slcp: \K(.*)' "${config_yml}")" - board="$(grep -oP 'board: \K(.*)' "${config_yml}")" + line="$(grep 'rcp_uart_slcp:' "${config_yml}")" + rcp_uart_slcp="${line//rcp_uart_slcp:/}" + line="$(grep 'rcp_spi_slcp:' "${config_yml}")" + rcp_spi_slcp="${line//rcp_spi_slcp:/}" + line="$(grep 'soc_slcp:' "${config_yml}")" + soc_slcp="${line//soc_slcp:/}" + line="$(grep 'board:' "${config_yml}")" + board="${line//board:/}" + + # Strip spaces + rcp_uart_slcp="${rcp_uart_slcp// /}" + rcp_spi_slcp="${rcp_spi_slcp// /}" + soc_slcp="${soc_slcp// /}" + board="${board// /}" # Strip quotes rcp_uart_slcp=$(eval echo "${rcp_uart_slcp}")