>
>According to [EMAIL PROTECTED] on 10/28/2006 9:42 PM:
>>     f1="/a/b/a-000"
>>     f2="/a/b/c d-000"
>>     touch "a-000.ext"
>>     touch "c d-000.ext"
>> 
>>     for file in "$(basename \"$f1\")"*.ext "$(basename \"$f2\")"*.ext
>>     do
>>      echo "one=$file"
>>     done
>> 
>>     for file in "`basename \"$f1\"`"*.ext "`basename \"$f2\"`"*.ext
>>     do
>>      echo "two=$file"
>>     done
>> -----------
>> 
>> The backticks work perfectly.
>> But the $() gets it very wrong and leaves a double-quote in the result.
>
>That's because `` and $() have different syntax, as required by POSIX.
>You should just do $(basename "$f1"), rather than $(basename \"$f1\").
>

That's crazy!

You have nested double quotes which don't need escaping?!

Let me think aloud:

    The first thing one encounters left-to-right is a double-quote.
    So, logic says that the quoted string is terminated by matching
    double-quote.

    Ok, so that means that the above is:
        "$(basename "
    followed by:
        $f1
    followed by:
        ")"

    which means that any spaces in $f1 are apparently unquoted and will
    therefore be subject to arg splitting.

    Therefore, there must be appropriate kludges in bash which make it work,
    despite the way in which it defies commonsense.

Looks like POSIX and commonsense are two different things.

Regards
Bahser



_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to