Question

I am writing a small shell script that launches a program in my wine directory. My challenge is that I have installed this on multiple machines, some with 64 and some with 32 bit, some with English and some with Norwegian locals.

the name of the program files directory in $HOME/.wine/drive_c can thus change from Program Files, Program Files (x86), programfiler etc..

The bash line I have so far is this:

(cd $HOME/.wine/drive_c/[Pp]rogram*/... ; wine ...)

However, the [Pp]rogram* line does not work, does anyone have a good suggestion?

Was it helpful?

Solution

That should work just fine, but since you will have both Program Files and Program Files (x86) on 64 bit installations this will always expand to Program Files which might be wrong in your case.

I would use the following to dynamically determine the correct path:

look_for='My Program/myprogram.exe'
for dir in "$HOME"/.wine/drive_c/[Pp]rogram*[Ff]*/; do
    if [ -e "${dir}${look_for}" ]; then
        cd "${dir}"
        wine [...]
        exit $?
    fi
done

This loops over all possible "program files" directories and checks if the file/directory specified in $look_for exists underneath it. If it does, it takes the directory component of $look_for, cds into it and runs wine from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top