mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-03 23:39:45 +01:00
Refactor strip_quote to use bash replacements instead of sed
This commit is contained in:
parent
6da72bcfd7
commit
1944eb8787
23
testssl.sh
23
testssl.sh
@ -853,17 +853,18 @@ is_number() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
strip_quote() {
|
strip_quote() (
|
||||||
# remove color codes (see https://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed)
|
# Note: parens in function definition here force this into a separate
|
||||||
# \', leading and all trailing spaces
|
# shell, preventing extglob from affecting the code outside this function
|
||||||
sed -e "s,$(echo -e "\033")\[[0-9;]*[a-zA-Z],,g" \
|
shopt -s extglob
|
||||||
-e "s/\"/\\'/g" \
|
# Remove color codes
|
||||||
-e 's/^ *//g' \
|
OUT=${1//$'\e['*([0-9;])[a-zA-Z]}
|
||||||
-e 's/ *$//g' <<< "$1"
|
# Replace quotes
|
||||||
}
|
OUT=${OUT//\"/\'}
|
||||||
|
strip_leading_space "$(
|
||||||
# " deconfuse vim\'s syntax highlighting ;-)
|
strip_trailing_space "$OUT"
|
||||||
|
)"
|
||||||
|
)
|
||||||
|
|
||||||
is_ipv4addr() {
|
is_ipv4addr() {
|
||||||
local octet="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])"
|
local octet="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])"
|
||||||
|
Loading…
Reference in New Issue
Block a user