Re: [PATCH v2] mergetools: add winmerge as a builtin tool
- From
Sebastian Schuberth <sschuberth@gmail.com>
- Date
- May 13, 2015, 20:00 UTC
- Message-ID
- <5553AD43.9010807@gmail.com>
- In-Reply-To
- <CAHGBnuPDSdCyVNM+Gagang1Cf9yw0Tyios45i6pnZSSzaJJC2Q@mail.gmail.com>
On 13.05.2015 17:33, Sebastian Schuberth wrote:
Show 17 quoted lines
>> In my tests, "$PROGRAMFILES(X86)" did *not* work:
>>
>> $ echo "$PROGRAMFILES(X86)"
>> bash: syntax error near unexpected token `('
>
> Interesting. In both MSYS1/2 Git Bashes I get on Windows 7 64-bit:
>
> $ echo "$PROGRAMFILES(X86)"
> C:\Program Files (x86)(X86)
>
> So it seems to resolve only the $PROGRAMFILES part and appending the
> literal "(X86)". Not sure how to tell Bash that "(X86)" is part of the
> variable name.
>
>> Exactly. In my tests, "$ProgramW6432" worked, while "$PROGRAMW6432" did not.
>
> Very odd indeed that for me it's the exact opposite.So how about something like this which hopefully covers all cases (including case-sensitivity issues regarding environment variable names and the problem of querying a variable that contains parentheses as part of its name):
for directory in "$(env | sed -nr 's/^PROGRAM(FILES(\(X86\))?|W6432)=//pI')"
do
test -n "$directory" &&
test -x "$directory/$winmerge_exe" &&
echo "$directory/$winmerge_exe" &&
break
donesed's "I" seems to be a GNU extension that's not available with OS X' BSD sed. This shouldn't be an issue as WinMerge is Windows only anyway. If it still turns out to be an issue we probably should come up with an equivalent Perl expression.
-- Sebastian Schuberth