From ea2dc8bd8ba8c49aa1e9d36170b42c2bb663fb99 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 26 Sep 2023 12:23:32 -0600 Subject: [PATCH] Housekeeping: egrep is deprecated Replace with grep -E Signed-off-by: Ed Santiago --- .github/workflows/orphan_vms.yml | 4 ++-- get_ci_vm/bad_repo_test/hack/get_ci_vm.sh | 8 ++++---- get_ci_vm/entrypoint.sh | 2 +- get_ci_vm/test.sh | 4 ++-- get_fedora_url.sh | 2 +- imgobsolete/entrypoint.sh | 8 ++++---- imgprune/entrypoint.sh | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/orphan_vms.yml b/.github/workflows/orphan_vms.yml index f6d441e8..e4502e6f 100644 --- a/.github/workflows/orphan_vms.yml +++ b/.github/workflows/orphan_vms.yml @@ -44,7 +44,7 @@ jobs: GCPPROJECT: 'libpod-218412' run: | export GCPNAME GCPJSON AWSINI GCPPROJECT - export GCPPROJECTS=$(egrep -vx '^#+.*$' $GITHUB_WORKSPACE/gcpprojects.txt | tr -s '[:space:]' ' ') + export GCPPROJECTS=$(grep -E -vx '^#+.*$' $GITHUB_WORKSPACE/gcpprojects.txt | tr -s '[:space:]' ' ') podman run --rm \ -e GCPNAME -e GCPJSON -e AWSINI -e GCPPROJECT -e GCPPROJECTS \ quay.io/libpod/orphanvms:latest \ @@ -59,7 +59,7 @@ jobs: - name: Count number of orphaned VMs id: orphans run: | - count=$(egrep -x '\* VM .+' /tmp/orphanvms_output.txt | wc -l) + count=$(grep -E -x '\* VM .+' /tmp/orphanvms_output.txt | wc -l) # Assist with debugging job (step-outputs are otherwise hidden) printf "Orphan VMs count:%d\n" $count if [[ "$count" =~ ^[0-9]+$ ]]; then diff --git a/get_ci_vm/bad_repo_test/hack/get_ci_vm.sh b/get_ci_vm/bad_repo_test/hack/get_ci_vm.sh index 22dbf0bc..5a7ecc52 100755 --- a/get_ci_vm/bad_repo_test/hack/get_ci_vm.sh +++ b/get_ci_vm/bad_repo_test/hack/get_ci_vm.sh @@ -66,9 +66,9 @@ delvm() { } image_hints() { - _BIS=$(egrep -m 1 '_BUILT_IMAGE_SUFFIX:[[:space:]+"[[:print:]]+"' \ + _BIS=$(grep -E -m 1 '_BUILT_IMAGE_SUFFIX:[[:space:]+"[[:print:]]+"' \ "$SECCOMPHOOKROOT/.cirrus.yml" | cut -d: -f 2 | tr -d '"[:blank:]') - egrep '[[:space:]]+[[:alnum:]].+_CACHE_IMAGE_NAME:[[:space:]+"[[:print:]]+"' \ + grep -E '[[:space:]]+[[:alnum:]].+_CACHE_IMAGE_NAME:[[:space:]+"[[:print:]]+"' \ "$SECCOMPHOOKROOT/.cirrus.yml" | cut -d: -f 2 | tr -d '"[:blank:]' | \ sed -r -e "s/\\\$[{]_BUILT_IMAGE_SUFFIX[}]/$_BIS/" | sort -u } @@ -141,7 +141,7 @@ cd $SECCOMPHOOKROOT # Attempt to determine if named 'oci-seccomp-bpf-hook' gcloud configuration exists showrun $PGCLOUD info > $TMPDIR/gcloud-info -if egrep -q "Account:.*None" $TMPDIR/gcloud-info +if grep -E -q "Account:.*None" $TMPDIR/gcloud-info then echo -e "\n${YEL}WARNING: Can't find gcloud configuration for 'oci-seccomp-bpf-hook', running init.${NOR}" echo -e " ${RED}Please choose '#1: Re-initialize' and 'login' if asked.${NOR}" @@ -151,7 +151,7 @@ then # Verify it worked (account name == someone@example.com) $PGCLOUD info > $TMPDIR/gcloud-info-after-init - if egrep -q "Account:.*None" $TMPDIR/gcloud-info-after-init + if grep -E -q "Account:.*None" $TMPDIR/gcloud-info-after-init then echo -e "${RED}ERROR: Could not initialize 'oci-seccomp-bpf-hook' configuration in gcloud.${NOR}" exit 5 diff --git a/get_ci_vm/entrypoint.sh b/get_ci_vm/entrypoint.sh index f5ac9959..c7797c98 100644 --- a/get_ci_vm/entrypoint.sh +++ b/get_ci_vm/entrypoint.sh @@ -235,7 +235,7 @@ has_valid_aws_credentials() { _awsoutput=$($AWSCLI configure list 2>&1 || true) dbg "$AWSCLI configure list" dbg "$_awsoutput" - if egrep -qx 'The config profile.+could not be found'<<<"$_awsoutput"; then + if grep -E -qx 'The config profile.+could not be found'<<<"$_awsoutput"; then dbg "AWS config/credentials are missing" return 1 elif [[ ! -r "$EC2_SSH_KEY" ]] || [[ ! -r "${EC2_SSH_KEY}.pub" ]]; then diff --git a/get_ci_vm/test.sh b/get_ci_vm/test.sh index a5f1f95d..e9e6b311 100755 --- a/get_ci_vm/test.sh +++ b/get_ci_vm/test.sh @@ -78,7 +78,7 @@ testf() { echo "# $@" > /dev/stderr fi - # Using egrep vs file safer than shell builtin test + # Using grep -E vs file safer than shell builtin test local a_out_f local a_exit=0 a_out_f=$(mktemp -p '' "tmp_${FUNCNAME[0]}_XXXXXXXX") @@ -109,7 +109,7 @@ testf() { if ((TEST_DEBUG)); then echo "Received $(wc -l $a_out_f | awk '{print $1}') output lines of $(wc -c $a_out_f | awk '{print $1}') bytes total" fi - if egrep -q "$e_out_re" "${a_out_f}.oneline"; then + if grep -E -q "$e_out_re" "${a_out_f}.oneline"; then _test_report "Command $1 exited as expected with expected output" "0" "$a_out_f" else _test_report "Expecting regex '$e_out_re' match to (whitespace-squashed) output" "1" "$a_out_f" diff --git a/get_fedora_url.sh b/get_fedora_url.sh index 21d132de..c925b5bc 100755 --- a/get_fedora_url.sh +++ b/get_fedora_url.sh @@ -67,7 +67,7 @@ else fi # Support both '.CHECKSUM' and '-CHECKSUM' at the end -filename=$(egrep -i -m 1 -- "$extension$" <<<"$by_arch" || true) +filename=$(grep -E -i -m 1 -- "$extension$" <<<"$by_arch" || true) [[ -n "$filename" ]] || \ die "No '$extension' targets among $by_arch" diff --git a/imgobsolete/entrypoint.sh b/imgobsolete/entrypoint.sh index 6727485f..c3425695 100755 --- a/imgobsolete/entrypoint.sh +++ b/imgobsolete/entrypoint.sh @@ -40,8 +40,8 @@ $GCLOUD compute images list --format="$FORMAT" --filter="$FILTER" | \ count_image reason="" created_ymd=$(date --date=$creationTimestamp --iso-8601=date) - permanent=$(egrep --only-matching --max-count=1 --ignore-case 'permanent=true' <<< $labels || true) - last_used=$(egrep --only-matching --max-count=1 'last-used=[[:digit:]]+' <<< $labels || true) + permanent=$(grep -E --only-matching --max-count=1 --ignore-case 'permanent=true' <<< $labels || true) + last_used=$(grep -E --only-matching --max-count=1 'last-used=[[:digit:]]+' <<< $labels || true) LABELSFX="labels: '$labels'" @@ -147,9 +147,9 @@ for (( i=nr_amis ; i ; i-- )); do done unset automation permanent reason - automation=$(egrep --only-matching --max-count=1 \ + automation=$(grep -E --only-matching --max-count=1 \ --ignore-case 'automation=true' <<< $tags || true) - permanent=$(egrep --only-matching --max-count=1 \ + permanent=$(grep -E --only-matching --max-count=1 \ --ignore-case 'permanent=true' <<< $tags || true) if [[ -n "$permanent" ]]; then diff --git a/imgprune/entrypoint.sh b/imgprune/entrypoint.sh index 442bf1d7..e3ab7bef 100755 --- a/imgprune/entrypoint.sh +++ b/imgprune/entrypoint.sh @@ -39,7 +39,7 @@ $GCLOUD compute images list --show-deprecated \ do count_image reason="" - permanent=$(egrep --only-matching --max-count=1 --ignore-case 'permanent=true' <<< $labels || true) + permanent=$(grep -E --only-matching --max-count=1 --ignore-case 'permanent=true' <<< $labels || true) [[ -z "$permanent" ]] || \ die 1 "Refusing to delete a deprecated image labeled permanent=true. Please use gcloud utility to set image active, then research the cause of deprecation." [[ "$dep_state" == "OBSOLETE" ]] || \