Meta: Use grep -E/F, not grep -P

grep -E and -F are POSIX standard, and meets all our matching needs.
This commit is contained in:
thislooksfun 2021-10-26 13:08:39 -05:00 committed by Andreas Kling
parent 4de7b3ad24
commit c2d44209a8
Notes: sideshowbarker 2024-07-18 01:37:08 +09:00
6 changed files with 10 additions and 10 deletions

View file

@ -9,7 +9,7 @@ MISSING_FILES=n
while IFS= read -r FILENAME; do
# Simply search whether the CMakeLists.txt *ever* mention the test files.
if ! grep -qP "${FILENAME}" Tests/AK/CMakeLists.txt ; then
if ! grep -qF "${FILENAME}" Tests/AK/CMakeLists.txt ; then
echo "Tests/AK/CMakeLists.txt is either missing the test file ${FILENAME} or is not in the commit's staged changes"
MISSING_FILES=y
fi

View file

@ -16,7 +16,7 @@ while IFS= read -r FLAG; do
# We simply search whether the CMakeLists.txt *ever* sets the flag.
# There are (basically) no false positives, but there might be false negatives,
# for example we intentionally don't check for commented-out lines here.
if ! grep -qP "set\(${FLAG}" Meta/CMake/all_the_debug_macros.cmake ; then
if ! grep -qF "set(${FLAG}" Meta/CMake/all_the_debug_macros.cmake ; then
echo "'all_the_debug_macros.cmake' is missing ${FLAG}"
MISSING_FLAGS=y
fi
@ -26,7 +26,7 @@ done < <(
'*.h' \
'*.in' \
':!:Kernel/FileSystem/ext2_fs.h' \
| xargs grep -P '(_DEBUG|DEBUG_)' \
| xargs grep -E '(_DEBUG|DEBUG_)' \
| sed -re 's,^.*[^a-zA-Z0-9_]([a-zA-Z0-9_]*DEBUG[a-zA-Z0-9_]*).*$,\1,' \
| sort \
| uniq

View file

@ -5,8 +5,8 @@ set -eo pipefail
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "${script_path}/.."
SYSCALLS_KERNEL="$(echo 'Kernel syscalls'; echo; grep -Pio '(?<=^ S\().*(?=\)( +\\)?$)' Kernel/API/Syscall.h | sort)"
SYSCALLS_UE="$(echo 'Implemented in UserspaceEmulator'; echo; grep -Pio '(?<=^ case SC_).*(?=:$)' Userland/DevTools/UserspaceEmulator/Emulator.cpp | sort)"
SYSCALLS_KERNEL="$(echo 'Kernel syscalls'; echo; grep -Eio '(?<=^ S\().*(?=\)( +\\)?$)' Kernel/API/Syscall.h | sort)"
SYSCALLS_UE="$(echo 'Implemented in UserspaceEmulator'; echo; grep -Eio '(?<=^ case SC_).*(?=:$)' Userland/DevTools/UserspaceEmulator/Emulator.cpp | sort)"
SYSCALLS_MAN2="$(echo 'Documented syscalls'; echo; find Base/usr/share/man/man2/ ! -type d -printf '%f\n' | sed -Ee 's,\.md,,' | sort)"
set +e

View file

@ -29,12 +29,12 @@ while read -r line; do
line_length=${#line}
category_pattern="^\S.*?\S: .+"
if [[ $line_number -eq 1 ]] && (echo "$line" | grep -P -v -q "$category_pattern"); then
if [[ $line_number -eq 1 ]] && (echo "$line" | grep -E -v -q "$category_pattern"); then
error "Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)"
fi
title_case_pattern="^\S.*?: [A-Z0-9]"
if [[ $line_number -eq 1 ]] && (echo "$line" | grep -P -v -q "$title_case_pattern"); then
if [[ $line_number -eq 1 ]] && (echo "$line" | grep -E -v -q "$title_case_pattern"); then
error "First word of commit after the subsystem is not capitalized"
fi
@ -43,7 +43,7 @@ while read -r line; do
fi
url_pattern="([a-z]+:\/\/)?(([a-zA-Z0-9_]|-)+\.)+[a-z]{2,}(:\d+)?([a-zA-Z_0-9@:%\+.~\?&\/=]|-)+"
if [[ $line_length -gt 72 ]] && (echo "$line" | grep -P -v -q "$url_pattern"); then
if [[ $line_length -gt 72 ]] && (echo "$line" | grep -E -v -q "$url_pattern"); then
error "Commit message lines are too long (maximum allowed is 72 characters)"
fi

View file

@ -5,7 +5,7 @@ set -eo pipefail
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path/.."
ALL_ENDPOINTS=$(find \( -name Toolchain -o -name Build -o -name .git -o -name Ports \) -prune -o -name '*.ipc' -print0 | xargs -0 grep -P '^endpoint ' | sort -k4 -n)
ALL_ENDPOINTS=$(find \( -name Toolchain -o -name Build -o -name .git -o -name Ports \) -prune -o -name '*.ipc' -print0 | xargs -0 grep -E '^endpoint ' | sort -k4 -n)
BAD_ENDPOINTS=$(echo "${ALL_ENDPOINTS}" | cut -d' ' -f4 | uniq -d)

View file

@ -7,7 +7,7 @@ cd "$script_path/.."
# The dollar symbol in sed's argument is for "end of line", not any shell variable.
# shellcheck disable=SC2016
grep -Pirh '(?<!file://)(?<!\.)(?<!})(?<!\()/(etc|res|usr|www)/' AK/ Base DevTools/ Documentation/ Kernel/ Services/ Userland/ | \
grep -Eirh '(?<!file://)(?<!\.)(?<!})(?<!\()/(etc|res|usr|www)/' AK/ Base DevTools/ Documentation/ Kernel/ Services/ Userland/ | \
sed -re 's,^.*["= `]/([^"%`: ]+[^"%`: /.])/?(["%`: .].*)?$,\1,' | \
sort -u | \
while read -r referenced_resource