From owner-freebsd-questions@FreeBSD.ORG Tue Dec 16 08:45:11 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B72E16A4CE for ; Tue, 16 Dec 2003 08:45:11 -0800 (PST) Received: from geminix.org (gen129.n001.c02.escapebox.net [213.73.91.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 278F143D1F for ; Tue, 16 Dec 2003 08:45:10 -0800 (PST) (envelope-from gemini@geminix.org) Message-ID: <3FDF3692.8070009@geminix.org> Date: Tue, 16 Dec 2003 17:45:06 +0100 From: Uwe Doering Organization: Private UNIX Site User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031206 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <1266318265.20031216170725@vkt.lt> In-Reply-To: <1266318265.20031216170725@vkt.lt> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Received: from gemini by geminix.org with asmtp (TLSv1:AES256-SHA:256) (Exim 3.36 #1) id 1AWIJo-000GcI-00; Tue, 16 Dec 2003 17:45:08 +0100 Subject: Re: bash bug or something else? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2003 16:45:11 -0000 hugle wrote: > Hello all. > I have a little problem in here. > Actulay i think, that bash doesn't caount good, look: > > cat bin/users | wc -l > 1877 > so the file contains 1877 lines > > cat bin/users: > #!/bin/sh > /sbin/ipfw -q delete 2001 >/dev/null 2>&1 & > /sbin/ipfw -q add 2001 count ip from 192.168.0.1 to not me in via fxp0 >/dev/null 2>&1 & > /sbin/ipfw -q delete 2002 >/dev/null 2>&1 & > /sbin/ipfw -q add 2002 count ip from not me to 192.168.0.1 out via fxp0 >/dev/null 2>&1 & > [...] > > so I should have 938 rules in my firewall. > 938 * 2=1876 + 1 = 1877 lines in the script (1 rule for delete rule > and one for add rule + rule at the top '#!/bin/sh') > > but when adding this rules to the ipfw ruleset i have: > ipfw show 2000-2938 | wc -l > 809 > > so somehere my 938-809=129 rules had just gone somewhere. > I'm using bash in here.. could that be a bug in bash ? No, it's not a bash bug. In your script the order of commands is relevant. 'delete' has to be executed prior to 'add' for the same rule number. If you send each line into background separately there is no guaranteed execution order. To fix this you need to remove the trailing ampersands from all the lines. And if you have to run this in background, send the whole script into background where you call it. Uwe -- Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers gemini@geminix.org | http://www.escapebox.net