-#!/bin/bash
-
-set -e
+#!/bin/sh -e
$NFT add table t
-$NFT destroy chain t nochain
+# pass for non-existent chain
+$NFT destroy chain t c
+
+# successfully delete existing chain
+$NFT add chain t c
+$NFT destroy chain t c
+++ /dev/null
-#!/bin/bash
-
-set -e
-
-$NFT add table t
-$NFT add chain t c
-
-$NFT destroy chain t c
+++ /dev/null
-table ip t {
-}
-#!/bin/bash
+#!/bin/sh -e
-set -e
$NFT add table t
-$NFT add flowtable t f { hook ingress priority 10 \; devices = { lo }\; }
+# pass for non-existent flowtable
+$NFT destroy flowtable t f
+
+# successfully delete existing flowtable
+$NFT add flowtable t f '{ hook ingress priority 10; devices = { lo }; }'
$NFT destroy flowtable t f
+++ /dev/null
-#!/bin/bash
-
-set -e
-$NFT add table t
-
-$NFT destroy flowtable t f
+++ /dev/null
-table ip t {
-}
-#!/bin/bash
-
-set -e
+#!/bin/sh -e
$NFT add table x
-$NFT add map x y { type ipv4_addr : ipv4_addr\; }
+# pass for non-existent map
+$NFT destroy map x y
+
+# successfully delete existing map
+$NFT add map x y '{ type ipv4_addr : ipv4_addr; }'
$NFT destroy map x y
+++ /dev/null
-#!/bin/bash
-
-set -e
-
-$NFT add table x
-
-$NFT destroy map x nonmap
+++ /dev/null
-table ip x {
-}
-#!/bin/bash
+#!/bin/sh -e
-set -e
$NFT add table t
$NFT add chain t c
+# pass for non-existent rule
$NFT destroy rule t c handle 3333
+
+# successfully delete existing rule
+handle=$($NFT -a -e insert rule t c accept | \
+ sed -n 's/.*handle \([0-9]*\)$/\1/p')
+$NFT destroy rule t c handle "$handle"
+++ /dev/null
-#!/bin/bash
-
-set -e
-$NFT add table t
-$NFT add chain t c
-$NFT insert rule t c accept # should have handle 2
-
-$NFT destroy rule t c handle 2
+++ /dev/null
-table ip t {
- chain c {
- }
-}
-#!/bin/bash
-
-set -e
+#!/bin/sh -e
$NFT add table x
-$NFT add set x s {type ipv4_addr\; size 2\;}
+# pass for non-existent set
+$NFT destroy set x s
+
+# successfully delete existing set
+$NFT add set x s '{type ipv4_addr; size 2;}'
$NFT destroy set x s
+++ /dev/null
-#!/bin/bash
-
-set -e
-
-$NFT add table x
-
-$NFT destroy set x s
+++ /dev/null
-table ip x {
-}