Whitelist/blacklist options result in grep errors

Title says it all, running in docker was trying to do a for loop to get black/whitelists out of a text file
for i in $(cat list); do pihole -b "$i"; done

pihole6:/# pihole -b example.com
grep: unrecognized option: P
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
        -o      Show only the matching part of line
        -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v      Select non-matching lines
        -s      Suppress open and read errors
        -r      Recurse
        -R      Recurse and dereference symlinks
        -i      Ignore case
        -w      Match whole words only
        -x      Match whole lines only
        -F      PATTERN is a literal (not regexp)
        -E      PATTERN is an extended regexp
        -m N    Match up to N times per file
        -A N    Print N lines of trailing context
        -B N    Print N lines of leading context
        -C N    Same as '-A N -B N'
        -e PTRN Pattern to match
        -f FILE Read pattern from file
grep: unrecognized option: P
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
        -o      Show only the matching part of line
        -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v      Select non-matching lines
        -s      Suppress open and read errors
        -r      Recurse
        -R      Recurse and dereference symlinks
        -i      Ignore case
        -w      Match whole words only
        -x      Match whole lines only
        -F      PATTERN is a literal (not regexp)
        -E      PATTERN is an extended regexp
        -m N    Match up to N times per file
        -A N    Print N lines of trailing context
        -B N    Print N lines of leading context
        -C N    Same as '-A N -B N'
        -e PTRN Pattern to match
        -f FILE Read pattern from file
  [✗] example.com is not a valid argument or domain name!

Thanks for bringing to to our attention, we have a PR aimed to resolve this by replacing pihole -q by a more modern variant, but it is still awaiting a certain decision, trying to get this rolling again.

This is an slightly different issue here: the v6 Docker image is alpine based which uses busybox as a multi-command binary. And the build-in grep does not offer the -P option.
We could add grep but this still does not work (notice: no issues running on bare metal)

014b4162b86:/# apk add grep
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
(1/1) Installing grep (3.10-r1)
Executing busybox-1.36.1-r2.trigger
OK: 51 MiB in 73 packages
a014b4162b86:/# pihole -b example.com
  [✗] example.com is not a valid argument or domain name!

vs

nanopi@nanopi:~$ pihole -b example.com
  [i] Adding example.com to the blacklist...
  [✓] Reloading DNS lists

The proper fix is using the PR listed above, which implements some bash functions to interact with the API, and re-implement pihole -b/-w on top of that.

can this be done via the api? or do you guys know a "high speed" way to add it to the database directly for the time being. I have a big-ol-list.

edit:
found a loophole using the api

for i in $(cat whitelist); do curl http(s)://piholedomain/api/domains/allow/exact -H "Content-Type: appication/json" -d "{ "domain": "$i" }" -X POST ; sleep 1 ; done