chore: Use grep -E / grep -F instead of egrep / fgrep (#2164)
Ensures that the -E or -F option, when used, is the first option * i.e. grep -oE => grep -E -o Updates _bash-it-grep to invoke grep with just the provided arguments * This function was (and still is) unused, but decided this new functionality was actually more useful Introduces _bash-it-fgrep to invoke grep -F Removes type -P egrep from the _bash-it-*grep functions For usages that were already going to be modified, use -F if appropriate * Does not touch grep usages that may have benefited from -F, but were not otherwise considered for this PR Adds shellcheck header to modified .bash files that didn't already have it
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'AWS helper functions'
|
||||
|
||||
@@ -40,13 +41,13 @@ function __awskeys_help {
|
||||
function __awskeys_get {
|
||||
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
|
||||
if [[ -n "${ln}" ]]; then
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 2 "aws_access_key_id|aws_secret_access_key"
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 1 "aws_session_token"
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 2 -e "aws_access_key_id" -e "aws_secret_access_key"
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 1 "aws_session_token"
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_list {
|
||||
local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)"
|
||||
local credentials_list="$((grep -E '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)"
|
||||
if [[ -n $"{credentials_list}" ]]; then
|
||||
echo -e "Available credentials profiles:\n"
|
||||
for profile in ${credentials_list}; do
|
||||
|
||||
@@ -30,8 +30,8 @@ function editpost() {
|
||||
pushd "${SITE}/_posts" > /dev/null || return
|
||||
|
||||
for POST in *; do
|
||||
DATE="$(echo "${POST}" | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")"
|
||||
TITLE="$(grep -oE "title: (.+)" < "${POST}")"
|
||||
DATE="$(echo "${POST}" | grep -E -o "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")"
|
||||
TITLE="$(grep -E -o "title: (.+)" < "${POST}")"
|
||||
TITLE="${TITLE/title: /}"
|
||||
echo "${COUNTER}) ${DATE} ${TITLE}"
|
||||
POSTS[COUNTER]="$POST"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'postgres helper functions'
|
||||
|
||||
@@ -50,7 +51,7 @@ function postgres_status {
|
||||
|
||||
|
||||
function is_postgres_running {
|
||||
$POSTGRES_BIN/pg_ctl -D $PGDATA status | egrep -o "no server running"
|
||||
$POSTGRES_BIN/pg_ctl -D $PGDATA status | grep -F -o "no server running"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user