packages icon indicating copy to clipboard operation
packages copied to clipboard

banIP: set pipefail + "| grep -q" / "| grep --quiet"

Open realizelol opened this issue 3 years ago • 3 comments

Maintainer: @dibdot Environment: amd64, generic, OpenWrt 21.02.3, r16554-1d4dea6d4f

Description: /usr/bin/banip.sh has set -o pipefail declared which isn't wrong but stop execution after piping to grep -q / grep --quiet with error 141. This is already a known bug: https://github.com/koalaman/shellcheck/issues/665 / https://github.com/koalaman/shellcheck/issues/1109 Also piping to head or grep -m or grep --max-counts shouldn't be working. (not tested)


I am actually doing this, which isn't the right way:

if [[ "$(opkg list-installed banip | awk '{print$3}')" == "0.7.10-3" ]]; then
  sed -i '/^set -o pipefail/d' /usr/bin/banip.sh
fi


best regards realizelol

realizelol avatar Jul 24 '22 14:07 realizelol

Oh btw I am using GNU grep:

opkg list-installed grep
grep - 3.6-1
grep -V
grep (GNU grep) 3.6
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

it can be tested by /usr/bin/banip.sh report cli

realizelol avatar Jul 24 '22 14:07 realizelol

What happend if you just remove the pipefail command?

dibdot avatar Aug 11 '22 19:08 dibdot

If I remove the pipefail the script will work finely.

Here's another sed after debug

/bin/sed -i -e 's!\(grep\) -q "\(.*\)" ||!\1 "\2" >/dev/null ||!g' -e 's!\(grep\) -q "\(.*\)";!\1 "\2" >/dev/null;!g' /usr/bin/banip.sh

realizelol avatar Aug 15 '22 13:08 realizelol

banIP has been updated, so issue of "0.7.10-3" has been resolved. #CLOSED

realizelol avatar May 16 '23 14:05 realizelol