From f6cda0db0d00af6b66877720971ea3446e9757dc Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 14 Apr 2026 19:52:51 -0400 Subject: [PATCH] small improvement --- brc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/brc b/brc index 3454360..bdfbaca 100644 --- a/brc +++ b/brc @@ -4870,10 +4870,11 @@ crypto() { cryptsetup luksOpen "$@" } -# iptables -I without duplication. -iptI() { ${*/ -I/ -C/} 2>/dev/null || "$@"; } -# iptables -A without duplication. -iptA() { ${*/ -A/ -C/} 2>/dev/null || "$@"; } +# ipti = iptables idempotent. Swaps -I/-A to -C to check if the rule exists, does not proceed if so. +# Usage: ipti IPTABLES_ARGS... (where IPTABLES_ARGS includes -I or -A). +# +# Note: due to code golf, it expects no spaces in the arguments. +ipti() { iptables ${*/ -[AI]/ -C/} 2>/dev/null || iptables "$@"; } ### how I calculated lswc-avg (at least for a btrfs filesystem): -- 2.30.2