bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash IFS bug....


From: Chet Ramey
Subject: Re: bash IFS bug....
Date: Thu, 15 Mar 2001 08:17:48 -0500

> Bash Version: 2.04
> Patch Level: 11
> Release Status: release
> 
> Description:
>       [Detailed description of the problem, suggestion, or complaint.]
> 
> parsing '/dos/work/win98sys/Program Files/Internet Explorer' with IFS='/' 
> each loop show the results like below

The results are correct.  Remember that when IFS is not exactly 
<space><tab><newline>, instances of IFS characters generate null
fields.

> ------------ begin of below --------------
> 
> ''
> 'dos'
> 'work'
> 'win98sys'
> 'Program'
> 'Files'
> 'Internet'
> 'Explorer'
> 
> --------------- end of below --------------
> 
> i think it seems has many trouble with many old bash scripts...
> 
> this is bug??? or added function???
> 
> troubled script is getting filename and extension from the full-path like 
> below...
> 
> 
> function parse_NE() {(
>       IFS="/"
>       rv=""
>       for f in $*; do
>               rv=$f
>               done
>       echo "$rv"
>       );}
> 
> this script don't work perfectly... T.T

You should make the loop look like
        for f ; do
                ...
        done

just on general principles.  It's better programming practice.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]