fix: remove deprecated egrep calls from codebase

This commit is contained in:
Jose Diaz-Gonzalez
2020-02-17 05:59:52 -05:00
parent b04080bcb1
commit e19b52442b
18 changed files with 33 additions and 34 deletions

View File

@@ -155,7 +155,7 @@ sigil:
docker:
apt-get install -qq -y curl
egrep -i "^docker" /etc/group || groupadd docker
grep -i -E "^docker" /etc/group || groupadd docker
usermod -aG docker dokku
ifndef CI
wget -nv -O - https://get.docker.com/ | sh
@@ -171,7 +171,7 @@ ifdef BUILD_STACK
@echo "Start building herokuish from source"
docker images | grep gliderlabs/herokuish || (git clone ${STACK_URL} /tmp/herokuish && cd /tmp/herokuish && IMAGE_NAME=gliderlabs/herokuish BUILD_TAG=latest VERSION=master make -e ${BUILD_STACK_TARGETS} && rm -rf /tmp/herokuish)
else
ifeq ($(shell echo ${PREBUILT_STACK_URL} | egrep -q 'http.*://|file://' && echo $$?),0)
ifeq ($(shell echo ${PREBUILT_STACK_URL} | grep -q -E 'http.*://|file://' && echo $$?),0)
@echo "Start importing herokuish from ${PREBUILT_STACK_URL}"
docker images | grep gliderlabs/herokuish || wget -nv -O - ${PREBUILT_STACK_URL} | gunzip -cd | docker import - gliderlabs/herokuish
else

2
debian/postinst vendored
View File

@@ -29,7 +29,7 @@ call-sshcommand() {
setup-user() {
echo "Setting up dokku user"
call-sshcommand create dokku /usr/bin/dokku
egrep -i "^docker" /etc/group || groupadd docker
grep -i -E "^docker" /etc/group || groupadd docker
usermod -aG docker dokku
mkdir -p "$DOKKU_ROOT/.ssh" "$DOKKU_ROOT/.dokkurc"
touch "$DOKKU_ROOT/.ssh/authorized_keys"

View File

@@ -762,7 +762,7 @@ get_ipv6_regex() {
get_dockerfile_exposed_ports() {
declare desc="return all exposed ports from passed file path"
local DOCKERFILE_PORTS=$(egrep "^EXPOSE " "$1" | awk '{ print $2 }' | xargs) || true
local DOCKERFILE_PORTS=$(grep -E "^EXPOSE " "$1" | awk '{ print $2 }' | xargs) || true
echo "$DOCKERFILE_PORTS"
}
@@ -796,7 +796,7 @@ extract_directive_from_dockerfile() {
declare desc="return requested directive from passed file path"
local FILE_PATH="$1"
local SEARCH_STRING="$2"
local FOUND_LINE=$(egrep "^${SEARCH_STRING} " "$FILE_PATH" | tail -n1) || true
local FOUND_LINE=$(grep -E "^${SEARCH_STRING} " "$FILE_PATH" | tail -n1) || true
echo "$FOUND_LINE"
}
@@ -858,7 +858,7 @@ internal_get_app_urls() {
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)
if [[ -s "$URLS_FILE" ]]; then
local app_urls="$(egrep -v "^#" "$URLS_FILE")"
local app_urls="$(grep -v -E "^#" "$URLS_FILE")"
if [[ -n "$DOKKU_PROXY_PORT_MAP" ]]; then
local port_map app_vhost
local app_vhosts=$(get_app_domains "$APP")

View File

@@ -63,7 +63,7 @@ domains_add() {
for DOMAIN in "$@"; do
if [[ $(
egrep -w "^$DOMAIN$" "$APP_VHOST_PATH" >/dev/null 2>&1
grep -w -E "^$DOMAIN$" "$APP_VHOST_PATH" >/dev/null 2>&1
echo $?
) -eq 0 ]]; then
dokku_log_info1 "Skipping: $DOMAIN already added to $APP"
@@ -165,7 +165,7 @@ domains_add_global() {
for DOMAIN in "$@"; do
if [[ $(
egrep -w "^$DOMAIN$" "$GLOBAL_VHOST_PATH" >/dev/null 2>&1
grep -w -E "^$DOMAIN$" "$GLOBAL_VHOST_PATH" >/dev/null 2>&1
echo $?
) -eq 0 ]]; then
dokku_log_info1 "Skipping: $DOMAIN already added"

View File

@@ -143,7 +143,7 @@ validate_ssl_domains() {
local SSL_HOSTNAME=$(get_ssl_hostnames "$APP")
local SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | xargs | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g' | sed 's/ /|/g')
if ! (egrep -q "^${SSL_HOSTNAME_REGEX}$" "$VHOST_PATH" &>/dev/null); then
if ! (grep -q -E "^${SSL_HOSTNAME_REGEX}$" "$VHOST_PATH" &>/dev/null); then
dokku_log_info1 "No matching configured domains for $APP found in SSL certificate. Your app will show as insecure in a browser if accessed via SSL"
dokku_log_info1 "Please add appropriate domains via the dokku domains command"
[[ -n "$NONSSL_VHOSTS" ]] && dokku_log_info1 "Configured domains for app:"
@@ -328,7 +328,7 @@ nginx_build_config() {
local SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | xargs | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g' | sed 's/ /|/g')
if [[ "$IS_APP_VHOST_ENABLED" == "true" ]]; then
local SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$" "$VHOST_PATH" || true)
local SSL_VHOSTS=$(grep -E "^${SSL_HOSTNAME_REGEX}$" "$VHOST_PATH" || true)
else
local SSL_VHOSTS=$(<"$DOKKU_ROOT/HOSTNAME")
fi

View File

@@ -85,7 +85,7 @@ EOF
mkdir -p "$NGINX_LOG_ROOT"
gpasswd -a dokku adm
chgrp --quiet -R adm "$NGINX_LOG_ROOT"
gpasswd -M "$(egrep ^dokku: /etc/group | awk -F ":" '{ print $4 }')" dokku
gpasswd -M "$(grep -E ^dokku: /etc/group | awk -F ":" '{ print $4 }')" dokku
[[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/create 0640 www-data dokku/create 0640 www-data adm/g' /etc/logrotate.d/nginx
# Create nginx error templates

View File

@@ -83,7 +83,7 @@ generate_scale_file() {
local NUM_PROCS=0
[[ "$NAME" == "web" ]] && NUM_PROCS=1
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >>"$DOKKU_SCALE_FILE"
done < <(egrep -v "^#" "$DOKKU_PROCFILE" | grep ':' | awk -F ':' '{ print $1 }' | sort | uniq)
done < <(grep -v -E "^#" "$DOKKU_PROCFILE" | grep ':' | awk -F ':' '{ print $1 }' | sort | uniq)
else
echo "web=1" >>"$DOKKU_SCALE_FILE"
fi
@@ -110,7 +110,7 @@ set_scale() {
fi
is_number "$PROC_COUNT" || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" >/dev/null 2>&1); then
if (grep -q -E "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" >/dev/null 2>&1); then
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE"
else
echo "$PROC_NAME=$PROC_COUNT" >>"$DOKKU_SCALE_FILE"

View File

@@ -16,7 +16,7 @@ trigger-scheduler-docker-local-core-post-deploy() {
fi
dokku_log_info1 "Renaming containers"
local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)"
local PROCTYPES="$(grep -v -E "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)"
local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)"
local CONTAINER_FILE

View File

@@ -18,7 +18,7 @@ trigger-scheduler-docker-local-post-delete() {
# remove all application containers & images
# shellcheck disable=SC2046
local DOKKU_APP_CIDS=$("$DOCKER_BIN" container list --all --no-trunc | egrep "dokku/${APP}:" | awk '{ print $1 }' | xargs)
local DOKKU_APP_CIDS=$("$DOCKER_BIN" container list --all --no-trunc | grep "dokku/${APP}:" | awk '{ print $1 }' | xargs)
if [[ -n "$DOKKU_APP_CIDS" ]]; then
# shellcheck disable=SC2086
"$DOCKER_BIN" container rm --force $DOKKU_APP_CIDS >/dev/null 2>&1 || true

View File

@@ -107,7 +107,7 @@ prime-ssh-known-hosts:
lint-setup:
@mkdir -p test-results/shellcheck tmp/shellcheck
@find . -not -path '*/\.*' -not -path './debian/*' -not -path './docs/*' -not -path './tests/*' -not -path './vendor/*' -type f | xargs file | grep text | awk -F ':' '{ print $$1 }' | xargs head -n1 | egrep -B1 "bash" | grep "==>" | awk '{ print $$2 }' > tmp/shellcheck/test-files
@find . -not -path '*/\.*' -not -path './debian/*' -not -path './docs/*' -not -path './tests/*' -not -path './vendor/*' -type f | xargs file | grep text | awk -F ':' '{ print $$1 }' | xargs head -n1 | grep -B1 "bash" | grep "==>" | awk '{ print $$2 }' > tmp/shellcheck/test-files
@cat tests/shellcheck-exclude | sed -n -e '/^# SC/p' | cut -d' ' -f2 | paste -d, -s > tmp/shellcheck/exclude
lint-ci: lint-setup
@@ -132,7 +132,7 @@ ci-go-coverage:
-w $(GO_REPO_ROOT) \
$(BUILD_IMAGE) \
bash -c "go get github.com/onsi/gomega github.com/schrej/godacov github.com/haya14busa/goverage && \
go list ./... | egrep -v '/vendor/|/tests/apps/' | xargs goverage -v -coverprofile=coverage.out && \
go list ./... | grep -v -E '/vendor/|/tests/apps/' | xargs goverage -v -coverprofile=coverage.out && \
godacov -t $$CODACY_TOKEN -r ./coverage.out -c $$CIRCLE_SHA1" || exit $$?
go-tests:
@@ -143,7 +143,7 @@ go-tests:
-w $(GO_REPO_ROOT) \
$(BUILD_IMAGE) \
bash -c "go get github.com/onsi/gomega && \
go list ./... | egrep -v '/vendor/|/tests/apps/' | xargs go test -v -p 1 -race" || exit $$?
go list ./... | grep -v -E '/vendor/|/tests/apps/' | xargs go test -v -p 1 -race" || exit $$?
unit-tests: go-tests
@echo running bats unit tests...

View File

@@ -20,7 +20,6 @@
# SC2174 - When used with -p, -m only applies to the deepest directory - https://github.com/koalaman/shellcheck/wiki/SC2174
# SC2179 - Use array+=("item") to append items to an array - https://github.com/koalaman/shellcheck/wiki/SC2179
# SC2191 - The = here is literal. To assign by index, use ( [index]=value ) with no spaces. To keep as literal, quote it - https://github.com/koalaman/shellcheck/wiki/SC2191
# SC2196 - egrep is non-standard and deprecated. Use grep -E instead - https://github.com/koalaman/shellcheck/wiki/SC2196
# SC2199 - Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @) - https://github.com/koalaman/shellcheck/wiki/SC2199
# SC2207 - Prefer mapfile or read -a to split command output (or quote to avoid splitting) - https://github.com/koalaman/shellcheck/wiki/SC2207
# SC2219 - Instead of 'let expr', prefer (( expr )) - https://github.com/koalaman/shellcheck/wiki/SC2219

View File

@@ -98,7 +98,7 @@ teardown() {
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 2"
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
echo "output: $output"
echo "status: $status"
assert_success
@@ -113,7 +113,7 @@ teardown() {
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
echo "output: $output"
echo "status: $status"
assert_success
@@ -147,7 +147,7 @@ teardown() {
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -86,7 +86,7 @@ teardown() {
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 2"
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
echo "output: $output"
echo "status: $status"
assert_success
@@ -103,7 +103,7 @@ teardown() {
CIDS+=" "
done
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -155,7 +155,7 @@ teardown() {
@test "(config) global config (herokuish)" {
deploy_app
run /bin/bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
run /bin/bash -c "dokku run $TEST_APP env | grep -E '^global_test=true'"
echo "output: $output"
echo "status: $status"
assert_success
@@ -163,7 +163,7 @@ teardown() {
@test "(config) global config (dockerfile)" {
deploy_app dockerfile
run /bin/bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
run /bin/bash -c "dokku run $TEST_APP env | grep -E '^global_test=true'"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -30,11 +30,11 @@ teardown() {
@test "(core) run (with --env / -e)" {
deploy_app
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | egrep '^TEST=testvalue'"
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
echo "output: $output"
echo "status: $status"
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | egrep '^TEST2=testvalue2'"
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -18,7 +18,7 @@ teardown() {
@test "(nginx-vhosts) nginx (no server tokens)" {
deploy_app
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'"
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | grep -E '^Server' | grep -E '[0-9]+'"
echo "output: $output"
echo "status: $status"
assert_failure

View File

@@ -24,7 +24,7 @@ teardown() {
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags $TEST_APP | egrep -q 'v0.9.0'"
run /bin/bash -c "dokku tags $TEST_APP | grep -q -E 'v0.9.0'"
echo "output: $output"
echo "status: $status"
assert_success
@@ -33,7 +33,7 @@ teardown() {
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku tags $TEST_APP | egrep -q 'v0.9.0'"
run /bin/bash -c "dokku tags $TEST_APP | grep -q -E 'v0.9.0'"
echo "output: $output"
echo "status: $status"
assert_failure
@@ -48,11 +48,11 @@ teardown() {
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker ps | egrep '/start web'| egrep -q dokku/${TEST_APP}:v0.9.0"
run /bin/bash -c "docker ps | grep -E '/start web'| grep -q -E dokku/${TEST_APP}:v0.9.0"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker images | egrep "dokku/${TEST_APP}"| egrep -q latest"
run /bin/bash -c "docker images | grep -E "dokku/${TEST_APP}"| grep -q -E latest"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -177,7 +177,7 @@ add_domain() {
# shellcheck disable=SC2119
check_urls() {
local PATTERN="$1"
run /bin/bash -c "dokku --quiet urls $TEST_APP | egrep \"${1}\""
run /bin/bash -c "dokku --quiet urls $TEST_APP | grep -E \"${1}\""
echo "output: $output"
echo "status: $status"
assert_success