diff --git a/scripts/lint_urls.sh b/scripts/lint_urls.sh index 7a016a679284..41cbff773844 100755 --- a/scripts/lint_urls.sh +++ b/scripts/lint_urls.sh @@ -13,7 +13,6 @@ running_jobs() { } while IFS=: read -r filepath url; do - fpath="$filepath" ( code=$(curl -k -gsLm30 --retry 3 --retry-delay 3 --retry-connrefused -o /dev/null -w "%{http_code}" -I "$url") || code=000 if [ "$code" -lt 200 ] || [ "$code" -ge 400 ]; then @@ -42,10 +41,10 @@ while IFS=: read -r filepath url; do fi fi if [ "$code" -lt 200 ] || [ "$code" -ge 400 ]; then - printf "${red}%s${reset} ${yellow}%s${reset} %s\n" "$code" "$url" "$fpath" >&2 + printf "${red}%s${reset} ${yellow}%s${reset} %s\n" "$code" "$url" "$filepath" >&2 exit 1 else - printf "${green}%s${reset} ${cyan}%s${reset} %s\n" "$code" "$url" "$fpath" + printf "${green}%s${reset} ${cyan}%s${reset} %s\n" "$code" "$url" "$filepath" exit 0 fi ) & @@ -53,19 +52,24 @@ while IFS=: read -r filepath url; do while [ "$(running_jobs)" -ge "$max_jobs" ]; do sleep 1 done -done < <( - git --no-pager grep --no-color -I -P -o \ - '(?!.*@lint-ignore)(?\")]*[<>\{\}\$])[^[:space:]<>\")\[\]\(\\]+' \ - -- '*' \ - ':(exclude).*' \ - ':(exclude,glob)**/.*' \ - ':(exclude,glob)**/*.lock' \ - ':(exclude,glob)**/*.svg' \ - ':(exclude,glob)**/*.xml' \ - ':(exclude,glob)**/*.gradle*' \ - ':(exclude,glob)**/*gradle*' \ - ':(exclude,glob)**/third-party/**' \ - ':(exclude,glob)**/third_party/**' \ + done < <( + pattern='(?!.*@lint-ignore)(?\")]*[<>\{\}\$])[^[:space:]<>")\[\]\\]+' + excludes=( + ':(exclude,glob)**/.*' + ':(exclude,glob)**/*.lock' + ':(exclude,glob)**/*.svg' + ':(exclude,glob)**/*.xml' + ':(exclude,glob)**/*.gradle*' + ':(exclude,glob)**/*gradle*' + ':(exclude,glob)**/third-party/**' + ':(exclude,glob)**/third_party/**' + ) + if [ $# -gt 0 ]; then + paths=("$@") + else + paths=('*') + fi + git --no-pager grep --no-color -I -P -o "$pattern" -- "${paths[@]}" "${excludes[@]}" \ | sed -E 's/[^/[:alnum:]]+$//' \ | grep -Ev '://(0\.0\.0\.0|127\.0\.0\.1|localhost)([:/])' \ | grep -Ev 'fwdproxy:8080' \ diff --git a/scripts/lint_xrefs.sh b/scripts/lint_xrefs.sh index 2df95f2a7ba3..7a26211b0108 100755 --- a/scripts/lint_xrefs.sh +++ b/scripts/lint_xrefs.sh @@ -18,16 +18,23 @@ while IFS=: read -r filepath link; do status=1 fi done < <( - git --no-pager grep --no-color -I -P -o \ - '(?!.*@lint-ignore)(?:\[[^]]+\]\([^[:space:])]*/[^[:space:])]*\)|href="[^"]*/[^"]*"|src="[^"]*/[^"]*")' \ - -- '*' \ - ':(exclude).*' \ - ':(exclude)**/.*' \ - ':(exclude)**/*.lock' \ - ':(exclude)**/*.svg' \ - ':(exclude)**/*.xml' \ - ':(exclude,glob)**/third-party/**' \ - ':(exclude,glob)**/third_party/**' \ + pattern='(?!.*@lint-ignore)(?:\[[^]]+\]\([^[:space:]\)]+/[^[:space:]\)]+\)|href="[^"]*/[^"]*"|src="[^"]*/[^"]*")' + excludes=( + ':(exclude,glob)**/.*' + ':(exclude,glob)**/*.lock' + ':(exclude,glob)**/*.svg' + ':(exclude,glob)**/*.xml' + ':(exclude,glob)**/*.gradle*' + ':(exclude,glob)**/*gradle*' + ':(exclude,glob)**/third-party/**' + ':(exclude,glob)**/third_party/**' + ) + if [ $# -gt 0 ]; then + paths=("$@") + else + paths=('*') + fi + git --no-pager grep --no-color -I -P -o "$pattern" -- "${paths[@]}" "${excludes[@]}" \ | grep -Ev 'https?://' \ | sed -E \ -e 's#([^:]+):\[[^]]+\]\(([^)]+)\)#\1:\2#' \