bug-bash
[Top][All Lists]
Advanced

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

Re: Encoding oddity


From: Dennis Williamson
Subject: Re: Encoding oddity
Date: Thu, 9 Dec 2010 23:26:27 -0600

On Thu, Dec 9, 2010 at 7:11 PM, Richard <ort_bash@bergersen.no> wrote:
> Hi!
>
> OS X 10.6.x
>
> I am trying to loop over some files with extended characters.
> Everything works fine if I hardcode the path, see example 1,
> but if I use a for loop with a * wildcard, I get some problems,
> see example 2.
>
> The problems seems to be that the extended character -- é -- in the
> hardcoded path, gets translated to the html equivalent of &#xE9,
> whereas the for loop with the wildcard, variable $b in the second example,
> translates the -- é -- to the html equivalent of &#x301.
>
> Due to this, [[ $b == $myfile ]] is never true in the second example, even 
> though
> it would be expected based on what I actually check for.
>
> Does anyone have any solution to this problem?
>
> Thanks!
>
>
> ------------------------------------------
> #!/bin/bash
>
> touch /Users/myuser/pretérito.txt
>
> # Example 1
> myfile="/Users/myuser/pretérito.txt"
>
> for b in "$myfile"; do
>        if [[ $b == $myfile ]]; then
>                echo "OK 1: $b ------ $myfile"
>        fi
> done
>
> # Example 2
> myfolder="/Users/myuser/"
> unset b
> for b in "$myfolder"*; do
>        if [[ $b == $myfile ]]; then
>                echo "OK 2: $b ------ $myfile"
>        fi
> done
> -----------------------------------------
>
> Richard Taubo
>

        if [[ $b == $myfolder$myfile ]]; then

Try

echo $myfolder/*

you will see that each file has the directory name prepended.



reply via email to

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