Skip to content

Commit

Permalink
Housekeeping: egrep is deprecated
Browse files Browse the repository at this point in the history
Replace with grep -E

Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago committed Sep 27, 2023
1 parent e5de95d commit ea2dc8b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/orphan_vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions get_ci_vm/bad_repo_test/hack/get_ci_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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}"
Expand All @@ -151,7 +151,7 @@ then

# Verify it worked (account name == [email protected])
$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
Expand Down
2 changes: 1 addition & 1 deletion get_ci_vm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions get_ci_vm/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion get_fedora_url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions imgobsolete/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'"

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion imgprune/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]] || \
Expand Down

0 comments on commit ea2dc8b

Please sign in to comment.