bug-bash
[Top][All Lists]
Advanced

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

Encoding oddity


From: Richard
Subject: Encoding oddity
Date: Fri, 10 Dec 2010 02:08:59 +0100

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


reply via email to

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