From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 6 07:12:57 2010 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD3E2106566C; Fri, 6 Aug 2010 07:12:57 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2D14E8FC20; Fri, 6 Aug 2010 07:12:56 +0000 (UTC) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id o767Ce0T023504; Fri, 6 Aug 2010 09:12:55 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id o767Cemx023503; Fri, 6 Aug 2010 09:12:40 +0200 (CEST) (envelope-from olli) Date: Fri, 6 Aug 2010 09:12:40 +0200 (CEST) Message-Id: <201008060712.o767Cemx023503@lurza.secnetix.de> From: Oliver Fromme To: eb30750@gmail.com, freebsd-bugs@FreeBSD.ORG, bug-followup@FreeBSD.ORG In-Reply-To: <201008051749.o75HnhkG083963@www.freebsd.org> X-Newsgroups: list.freebsd-bugs User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.4 (lurza.secnetix.de [127.0.0.1]); Fri, 06 Aug 2010 09:12:56 +0200 (CEST) Cc: Subject: Re: misc/149335: shell script runs on Linux but not on freebsd X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: eb30750@gmail.com, freebsd-bugs@FreeBSD.ORG, bug-followup@FreeBSD.ORG List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2010 07:12:57 -0000 Paul Lambert wrote: > > Number: 149335 > > Category: misc > > Synopsis: shell script runs on Linux but not on freebsd > [...] > > Environment: > FreeBSD BRSINC-VM02.local 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 > > Description: > The script fails on these two lines so far; "stat" and "od" > > # This won't work with non-GNU stat. > FILE_SIZE=`stat --format "%s" "$0"` > offset=$(($FILE_SIZE - 4)) As the comment suggests, that command is non-portable and works with GNU stat (linux) only. This is not a standard. The equivalent BSD command line would be: FILE_SIZE=`stat -f %z "$0"` I wonder why the script even needs to find out its own size, and then read binary data from itself?!? Is this some kind of "copy protection" or similar tricks? If so, I suspect that it is highly non-portable and will be difficult to get to run on anything else than linux. > # XXX: put extraction in its own function > MAGIC_NUMBER=`od -An -t u4 -N 4 -j $MAGIC_OFFSET "$file" | tr -d ' '` This command works fine on FreeBSD 8.1. If it doesn't work in the context of the script, I suspect that it is caused by preceding problems that set one of the variables to a wrong value. As a work-around, you might try running the script with /compat/linux/bin/sh instead of /bin/sh. You need to enable Linux compatibility ("kldload linux") and install ports/emulators/linux_base-f10 if you don't have it already. As this is not a bug in FreeBSD, I suggest that this PR can be closed. Do you agree? Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "Unix gives you just enough rope to hang yourself -- and then a couple of more feet, just to be sure." -- Eric Allman