From owner-freebsd-questions Mon Jan 17 17: 4:30 2000 Delivered-To: freebsd-questions@freebsd.org Received: from pau-amma.whistle.com (pau-amma.whistle.com [207.76.205.64]) by hub.freebsd.org (Postfix) with ESMTP id C029614F17 for ; Mon, 17 Jan 2000 17:04:25 -0800 (PST) (envelope-from dhw@whistle.com) Received: (from dhw@localhost) by pau-amma.whistle.com (8.9.2/8.9.2) id QAA73150 for freebsd-questions@freebsd.org; Mon, 17 Jan 2000 16:46:03 -0800 (PST) Date: Mon, 17 Jan 2000 16:46:03 -0800 (PST) From: David Wolfskill Message-Id: <200001180046.QAA73150@pau-amma.whistle.com> To: freebsd-questions@freebsd.org Subject: /bin/sh in FreeBSD-2.10-R gets "Syntax error: Bad substitution" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG One of our servers is (still!) running FreeBSD-2.1.0-R (because I haven't figured out how to upgrade it with as little disruption as I'm comfortable with). I've been upgrading the version of the BIND package running on various machines -- a Solaris 2.6 box & 3 FreeBSD (3.2-R) boxen at home yesterday, and I did a couple of FreeBSD boxen here at work this morning (3.1-R & 2.2.6-R). But this one that's running 2.1.0-R chokes in trying to deal with the src/port/settings script during the initial "make clean": whistle# 27 make clean Making /usr/local/src/bind-8.2.2.P5/src/.systype Making .settings port/settings: 1: Syntax error: Bad substitution *** Error code 2 Stop. OK; so that's a Bad Thing. :-( So I tried to figure out what was going on: whistle# 35 make -n set -e; version=`cat Version`; systype=`sh port/systype .systype`; if [ $systype = "unknown" ]; then echo "There is no BIND port for this system in this kit."; else settings=`sh port/settings .settings < port/$systype/Makefile.set`; PATH=`pwd`/port/$systype/bin:$PATH; export PATH; for x in include port lib bin; do ( cd $x; pwd; eval "make $settings SYSTYPE=$systype VER=$version all"; ); done fi OK... so port/settings is just a shell script; I copied it to /tmp and inserted set -x set -v just after the #!/bin/sh line. Then: whistle# 36 sh # set -e # export version;version=`cat Version` # echo $version 8.2.2-P5 # export systype;systype=`sh port/systype .systype` Using .systype # echo $systype freebsd # export settings;settings=`sh /tmp/settings .settings < port/$systype/Makefile.set` + set -v + cachefile=.settings + [ -f .settings ] + echo Making .settings Making .settings + LC_COLLATE=C + export LC_COLLATE + result= /tmp/settings: 1: Syntax error: Bad substitution whistle# 37 Bleagh.... So I fired up an xterm for the only general-purpose computer left at home that didn't get the BIND upgrade over the weekend -- a Sun 3/60, running SunOS 4.1.1_U1. And the "make clean" (and other stuff, though it's only perhaps halfway through the "make all"; I only started it about 30 minutes ago -- Sun 3/60s aren't overwhelmingly fast (any more)) works just fine there... so I'm wondering if possibly there was a bug in FreeBSD's /bin/sh circa 2.1.0-R that I might be able to circumvent. Here's the script (as modified with the additional "set" statements): -------------%<------------------------------- #!/bin/sh set -x set -v # this process is necessary because make(1) puts its command line into # the environment, and when we exec a sub-make we need these command # line settings (like CDEBUG=-g for example) to override what we get out # of port/$systype/Makefile.set. therefore feed Makefile.set to this # and it will merge things appropriately. a cache file is maintained # to avoid calling this script way too often. cachefile=${1-//} if [ -f "$cachefile" ]; then echo "Using $cachefile" >&2 exec cat $cachefile fi case $cachefile in //) ;; *) echo "Making $cachefile" >&2 ;; esac # expr is sensitive to LC_COLLATE settings. We want 'C'. LC_COLLATE=C export LC_COLLATE result='' while read setting; do var=`expr "$setting" : "'\([A-Z0-9_]*\)="` val=`expr "$setting" : "'[A-Z0-9_]*=\([^']*\)'\$"` eval "env=`echo \\${\$var-'$val'}`" result="$result '$var=$env'" done case $cachefile in //) echo $result ;; *) echo $result > $cachefile exec cat $cachefile ;; esac exit ------------->%------------------------------- (Yes, I *know* I need to upgrade the machine. It is running some rather mission-critical workload, such as being a critical internal mail relay & nameserver. I've been working on lessening our dependence on the one machine, in preparation for replacing it. But I have a few other things to do, too....) Thanks in advance, david -- David Wolfskill dhw@whistle.com UNIX System Administrator voice: (650) 577-7158 pager: (888) 347-0197 FAX: (650) 372-5915 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message