On 13.05.2015 17:33, Sebastian Schuberth wrote: >> 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 done sed'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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html