vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > -----Original Message----- > From: listmaster@xenitec.on.ca > [mailto:listmaster@xenitec.on.ca] On Behalf Of Scott McMillan > Sent: Thursday, January 22, 2004 1:43 PM > To: distribution@xenitec.on.ca > Subject: Re: Losing variables after IFS > > > On Thu, 22 Jan 2004 19:21:25 GMT, Fabio Giannotti <fabiog@venmar.com> > wrote: > > > > > > >> -----Original Message----- > >> From: listmaster@xenitec.on.ca > >> [mailto:listmaster@xenitec.on.ca] On Behalf Of Scott McMillan > >> Sent: Thursday, January 22, 2004 12:53 PM > >> To: distribution@xenitec.on.ca > >> Subject: Losing variables after IFS > >> > >> > >> Hello all, > >> > >> I hope someone can point me in the right direction. I have > >> the following script burned to CD-ROM using mkisofs v1.14 and > >> cdrecord 1.10 - both precompiled SCO Openserver binaries > >> running on OSR5.0.6: > >> > >> # more test > >> #!/bin/sh > >> cd /tmp > >> COPY="copy -omv" > >> $COPY /mnt/tst1.txt sdm1 > >> IFS=`` > >> $COPY /mnt/tst1.txt sdm2 > >> > >> I mount the CD on my SCO system, and run the 'test' > script: # ls -l > >> /tmp total 0 > >> # mount /dev/cd0 /mnt > >> # ls -l /mnt > >> total 4 > >> -rwxr-xr-x 1 root sys 92 Jan 22 08:21 test > >> -rw-rw-rw- 1 root sys 29 Jan 22 08:20 tst1.txt > >> > >> # /mnt/test > >> copy file /mnt/tst1.txt > >> /mnt/test: copy -omv: not found > >> > >> # ls -l /tmp > >> total 2 > >> -rw-rw-rw- 1 root sys 29 Jan 22 08:20 sdm1 > >> > >> As you can see, the first copy works fine, but my IFS= > >> definition seems to 'break' my $COPY variable definition. > >> This ONLY occurs when running the script on CD - Other > >> installations that extract from tape/floppy (using tar) to > >> the HD perform everything as expected. > >> > >> Can someone explain to me what the IFS=`` does to my $COPY? > >> I'm not sure if it's due to the shell (Bourne), something to > >> do with the mkisofs/cdrecord I'm using, etc. > >> > >Scott, > > > >That's really odd. I just tried it on my system and it has > the exact > >same effect, even though I'm not doing anything with a CD. > That is, I > >just created a little script and ran it from root and > "broke" exactly > >the same way. > > > >That is, setting it to null with either double quotes, > single quotes or > >back quotes causes the same behavior. Basically, after > setting IFS to > >null the system sees the entire variable "copy -vom" as one > string, not > >two seperate strings seperated by a space. > > > >So, you can't set IFS to null and have it work. > > > >You can see what setting IFS is doing by looking at the following: > >IFS=";" COPY="copy;-vom" > >$copy file1 file2 > > > >Good luck, > >Fabio > > Hi Fabio, > > Well, after reading your reply, I went back to my install > scripts (the above is just to recreate the problem) and found > that you are right, it's NOT just on CDs. My real scripts > are finished with all variables BEFORE the IFS= line, so the > issue never showed itself. Sorry for that bit of mis-information. > > But I'm not really sure I understand your example above. Is > IFS _inserting_ it's value into my COPY variable, in place of > a space? If so, I've been misinterpreting its use for awhile > now, and better get back to RTFM! > Scott, My understanding is (and I could be way off here) is that IFS is what the shell uses to tell where the "breaks" in a string should be. So, if you set IFS to ";", then you need to put a ";" instead of a space to break apart parts of the command. It's not inserting anything, it's just telling the shell what to look for. Hope this helps, Fabio |