]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:tests: Fix shellcheck warning of test_wbinfo_lookuprids_cache.sh
authorAndreas Schneider <asn@samba.org>
Tue, 5 Aug 2025 09:11:10 +0000 (11:11 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 5 Aug 2025 11:50:32 +0000 (11:50 +0000)
In source3/script/tests/test_wbinfo_lookuprids_cache.sh line 27:
key=$("$TDBDUMP" "$cache" | grep ^key.*NDR.*/"$opnum"/ | cut -d\" -f2)
                                 ^-------------------^ SC2062 (warning):
                                 Quote the grep pattern so the shell won't
                                 interpret it.

Lets better use awk for matching the pattern.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/script/tests/test_wbinfo_lookuprids_cache.sh

index fef4e04b36958fe16efca4c3cc43996cfbcafe00..2f441d21af3dcb7bfd59d56f59d1bf9187fae43b 100755 (executable)
@@ -24,7 +24,7 @@ testit "flush" "$NET" "cache" "flush" || failed=$(expr $failed + 1)
 testit "lookuprids1" "$WBINFO" "-R" "512,12345" || failed=$(expr $failed + 1)
 
 opnum=$($PYTHON -c'from samba.dcerpc.winbind import wbint_LookupRids; print(wbint_LookupRids.opnum())')
-key=$("$TDBDUMP" "$cache" | grep ^key.*NDR.*/"$opnum"/ | cut -d\" -f2)
+key=$("$TDBDUMP" "$cache" | awk -F'"' -v opnum="${opnum}" '/key.*NDR/ { regex = "NDR/[^/]+/" opnum "/.*$"; if (match($2, regex)) print substr($2, RSTART, RLENGTH) }')
 
 testit "delete" "$TDBTOOL" "$cache" delete "$key"
 testit "lookuprids2" "$WBINFO" "-R" "512,12345" || failed=$(expr $failed + 1)