From owner-freebsd-bugs Sat Apr 26 05:00:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA20065 for bugs-outgoing; Sat, 26 Apr 1997 05:00:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA20040; Sat, 26 Apr 1997 05:00:02 -0700 (PDT) Date: Sat, 26 Apr 1997 05:00:02 -0700 (PDT) Message-Id: <199704261200.FAA20040@hub.freebsd.org> To: freebsd-bugs Cc: From: John-Mark Gurney Subject: Re: bin/3387: sh mis-interpret the file name / awk failure Reply-To: John-Mark Gurney Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/3387; it has been noted by GNATS. From: John-Mark Gurney To: jin@adv-pc-1.lbl.gov Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/3387: sh mis-interpret the file name / awk failure Date: Sat, 26 Apr 1997 04:51:39 -0700 Jin Guojun[ITG] scribbled this message on Apr 25: > >Description: > > In a script, if the variable for a file name had a white space at > the end, the sh will treat it differently when the file name variable > is used at redirected I/O, from used at fopen(). The white space is > interpreted as part of the file name when I/O redirections, such as, > '<', '<<', '>>', and '>' are used. This is a problem for using in > a script. > The FreeBSD awk generates such withe space: > > MyArch=`uname -v | awk -F/ '{printf $NF}` > echo "=$MyArch=" > =GENERIC = > > I am not sure which one is the problem, maybe both. but of course... when you do the MyArch... it will store EXACTLY what awk outputed... and that is with a \n at the end... one simple fix is: MyArch=`uname -v | awk -F/ '{printf("%s", $NF)}'` MyArch=`echo $MyArch` echo "=$MyArch=" the second setting of MyArch eliminates the \n at the end... I had a simlar problem with a script I was writing... it's just that borne shell does EXACTLY what you tell it... :) > >How-To-Repeat: > > For awk problem, see Description above. > Below is the sh issue: > > % more abc > file abc is a testing file > > % more test.script > FILE_NAME="abc " > more < $FILE_NAME > echo "=$FILE_NAME=" > more $FILE_NAME > > % test.script > test.script: cannot open abc : no such file > =abc = > file abc is a testing file this is just as easy... basicly sh does the variable expansion.. then it does the "parsing" of the command line options... if you replaced the second more with: more "$FILE_NAME" you would have the same problem... if you don't have any objections (as this is borne shell's expected behavior), I'll close this.. ttyl.. -- John-Mark Cu Networking Modem/FAX: +1 541 683 6954 Live in Peace, destroy Micro$oft, support free software, run FreeBSD