Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Aug 2018 19:34:47 +0300
From:      "Andrey V. Elsukov" <bu7cher@yandex.ru>
To:        rgrimes@freebsd.org
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r337536 - head/sbin/ipfw
Message-ID:  <640fc2e6-9332-2b59-c6ad-b0fd42dae7f2@yandex.ru>
In-Reply-To: <201808091619.w79GJ9lp018293@pdx.rh.CN85.dnsmgr.net>
References:  <201808091619.w79GJ9lp018293@pdx.rh.CN85.dnsmgr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--o4EFbxeT5wmGonS9hninS7cVFGEJvMOfc
Content-Type: multipart/mixed; boundary="ED60JM1c6I2rSV9k2NyRGw4OwEhDoinM2";
 protected-headers="v1"
From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: rgrimes@freebsd.org
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Message-ID: <640fc2e6-9332-2b59-c6ad-b0fd42dae7f2@yandex.ru>
Subject: Re: svn commit: r337536 - head/sbin/ipfw
References: <201808091619.w79GJ9lp018293@pdx.rh.CN85.dnsmgr.net>
In-Reply-To: <201808091619.w79GJ9lp018293@pdx.rh.CN85.dnsmgr.net>

--ED60JM1c6I2rSV9k2NyRGw4OwEhDoinM2
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

On 09.08.2018 19:19, Rodney W. Grimes wrote:
>>>> table add/delete commands had the same behavior, "nat" already noted=
 in
>>>> this list. What is the usage scenario do you use, where you need to =
fail
>>>> on bad delete?
>>>
>>> if [ ipfw delete ${1} ]; then
>>> 	handle the missing rule
>>> fi
>>
>> This is mostly unneeded operation, that we wanted to avoid.
>> I.e. to be able run in bath mode:
>>
>> delete ${n}
>> add ${n} ...
>=20
> That is one use case, but any shell script worth writting
> is worth writting to handle error conditions, and not being
> able to handle errors while being silent is a PITA.

Ok, I still don't understand the usefulness of knowing the error
code of delete command. But, I can propose the following solution:
Index: ipfw2.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ipfw2.c	(revision 337541)
+++ ipfw2.c	(working copy)
@@ -3314,7 +3314,7 @@ ipfw_delete(char *av[])
 			}
 		}
 	}
-	if (exitval !=3D EX_OK && co.do_quiet =3D=3D 0)
+	if (exitval !=3D EX_OK && co.do_force =3D=3D 0)
 		exit(exitval);
 }


With this patch -q will work as "quiet", -f will work as "force".
So, you can still get error code in shell script, and I can run batched
commands with -q -f:

# ipfw -f delete 10000-11000 ; echo $?
ipfw: no rules rules in 10000-11000 range
0
# ipfw -qf delete 10000-11000 ; echo $?
0
# ipfw -q delete 10000-11000 ; echo $?
69

Are you fine with this?

--=20
WBR, Andrey V. Elsukov


--ED60JM1c6I2rSV9k2NyRGw4OwEhDoinM2--

--o4EFbxeT5wmGonS9hninS7cVFGEJvMOfc
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAltsbScACgkQAcXqBBDI
oXqBkwf+O4mBg6wo0VC19fS4aIfej3CwSJ7i82sxmb9kaf5jGTwX5qudvEwb8dz5
bHeFq4eTNw3feECgtAaPaFIi6eKZwuuK+oL0w/dvssDUIiak4RYMVG4slkI5HgiQ
qTaZTD8otIJFexKW+AKd5SpB0IsGN2zAdAJXXBpVCuFlpi3Bkpu1yo3DRs5vRBGF
S8gFM/rndmTQrzbPPug/MHt7QWhzTcapoxTmuCKJqjumhNqFdbYACLfyQdtNxhLG
evFWC2UE7GiQbEYvXjmghJ15J9LI1ozyYDeGxQI6LG+yMgoHc6C5oZs1VK3Nk46Q
mR57mCnBuX7HXWdeTpDBv/t0agOnHQ==
=Ogot
-----END PGP SIGNATURE-----

--o4EFbxeT5wmGonS9hninS7cVFGEJvMOfc--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?640fc2e6-9332-2b59-c6ad-b0fd42dae7f2>