misc/149335: shell script runs on Linux but not on freebsd

Paul Lambert eb30750 at gmail.com
Thu Aug 5 17:50:10 UTC 2010

>Number:         149335
>Category:       misc
>Synopsis:       shell script runs on Linux but not on freebsd
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 05 17:50:09 UTC 2010
>Originator:     Paul Lambert
>Release:        8.,1-release
FreeBSD BRSINC-VM02.local 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
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))

   # XXX: put extraction in its own function
   MAGIC_NUMBER=`od -An -t u4 -N 4 -j $MAGIC_OFFSET "$file" | tr -d ' '`

   if [ "$MAGIC_NUMBER" != "907380241" ]; then
      echo "magic number does not match"
      #exit 1


The linux Bash version is 4.1.7(1) and the installed freebsd is 4.1.7(0)-release


More information about the freebsd-bugs mailing list