Bottles icon indicating copy to clipboard operation
Bottles copied to clipboard

[Bug]: Bottles CLI issue passing arguments (not escaping correctly)

Open gr225 opened this issue 1 year ago • 8 comments

Describe the bug

There is an issue with the arguments (-a) parameter in "bottles-cli run" in which it will not escape if the executable also uses a dash (-) parameter (argument). It assumes it's part of the bottles-cli command instead.

Passing an argument via the configuration file works, but not via CLI. It's important that bottles-cli escapes the argument so that more complex scripting can send a variable to the application running in bottles.

This is preventing me from running a particular application which otherwise works fantastic in bottles. Unfortunately the application requires a command line parameter with a dash and then a variable to be injected from MIME URL.

Maybe I'm missing something, or if not, then hopefully a solution can be found to allow us to pass these types of arguments.

To Reproduce

The issue can be reproduced with an application that requires the use of a dash-based argument, even if it's the same. Enclosing in quotes should escape it. I've tried single quotes and \ to escape but nothing works.

bottles-cli run -b testbottle -p testapp -a "-a variable"

bottles-cli run -b testbottle -p testapp -a "-z"

bottles-cli run -b testbottle -p testapp -a "-launch"

Bottles returns an error regarding unexpected argument.

Package

Flatpak from Flathub

Distribution

Fedora 36

Troubleshooting Logs

Version: 2022.8.28-brescia-2
Display:
    X.org: true
    X.org (port): :99.0
    Wayland: true
Graphics:
    vendors:
        intel:
            vendor: intel
            envs:
                DRI_PRIME: '1'
            icd: /usr/lib/x86_64-linux-gnu/GL/vulkan/icd.d/intel_icd.x86_64.json:/usr/lib/i386-linux-gnu/GL/vulkan/icd.d/intel_icd.i686.json
    prime:
        integrated: null
        discrete: null
Kernel:
    Type: Linux
    Version: 5.19.8-200.fc36.x86_64
Distro:
    Name: GNOME
    Version: '"42 (Flatpak runtime)"'
Disk:
    Total: 7962492928
    Free: 7962341376
RAM:
    MemTotal: 14.8GiB
    MemAvailable: 9.8GiB
Bottles_envs: null

Display Protocol

Wayland

Display Backend used by Bottles

Wayland

Additional context

No response

gr225 avatar Sep 17 '22 21:09 gr225

I'm not able to replicate, doing:

flatpak run --command=bottles-cli com.usebottles.bottles -b MyBottle -p MyApp -a "arg1 arg2 arg3"

works as expected.

mirkobrombin avatar Sep 25 '22 13:09 mirkobrombin

I mean if the application requires a dash - flag;

flatpak run --command=bottles-cli com.usebottles.bottles -b MyBottle -p MyApp -a "-a arg1 -b arg2 -c arg3"

in this case the -a -b -c are evaluated by bottles-cli and not escaped to be passed to the application.

gr225 avatar Sep 25 '22 13:09 gr225

Still having an issue with this. This is an example of the issue I'm having:

flatpak run --command=bottles-cli com.usebottles.bottles -b bottle -p application -a '-a "123e4567-e89b-12d3-a456-426614174000"'

The application takes a variable via the same -a argument, but it's instead evaluated by bottles-cli. The problem is the application expects the variable passed to -a is quoted too. I need a way of escaping it.

Is there anyway to get this to work?

gr225 avatar Oct 20 '22 15:10 gr225

Hi gr225,

I just developed a workaround for a similar problem (Bottles passing incorrect arguments to Windows programs) by pre-processing the arguments in the CLI command. Maybe you can adapt my solution. Please see How to click on a file in Linux and have a Bottles Windows program open and load that file

Good luck...

ebaldino avatar Oct 22 '22 01:10 ebaldino

Hi gr225,

I just developed a workaround for a similar problem (Bottles passing incorrect arguments to Windows programs) by pre-processing the arguments in the CLI command. Maybe you can adapt my solution. Please see How to click on a file in Linux and have a Bottles Windows program open and load that file

Good luck...

Thanks - not sure this will work for this particular application unfortunately. I'm not sure that we can really 'escape' the -a parameter. The application requires -a to take the variable I'm passing to it, but there's no way to stop bottles-cli assuming it's for itself.

One solution I can think of is if bottles-cli could still run the configured start parameter for that bottles application (which could be set at -a in this case), and then extra variables can be 'added' by the command -a in the cli.

gr225 avatar Oct 22 '22 08:10 gr225

Maybe you can escape the -a with a backslash. Here's what I tried.

I started Word from the command line with this:

flatpak -v run --command=bottles-cli com.usebottles.bottles run -b 'Office2007' -e '/home/eduardo/.var/app/com.usebottles.bottles/data/bottles/bottles/Office2007/drive_c/Program Files/Microsoft Office/Office12/WINWORD.EXE' -a '\-a "123e4567-e89b-12d3-a456-426614174000"'

Then, in Word, I used a short VBA to print out the command line used to start Word, and I got this:

"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" -a 123e4567-e89b-12d3-a456-426614174000

So it appears the arguments were passed in as expected.

ebaldino avatar Oct 22 '22 13:10 ebaldino

I hope will be partially solved in next release via https://github.com/bottlesdevs/Bottles/pull/2342 Partially, because there is still problem with escaping &, I'm working on in #2361

psydvl avatar Dec 13 '22 20:12 psydvl

Using Bottles 51.11, the escaped arguments now seem to get passed to vmtouch instead.

flatpak run --command=bottles-cli com.usebottles.bottles run -b main -e "./BlupiMania-2.exe" -- -nocdBM2

results in

/app/bin/vmtouch: invalid option -- 'n' /app/bin/vmtouch: invalid option -- 'n'

vmtouch v1.3.1 - the Virtual Memory Toucher by Doug Hoyte Portable file system cache diagnostics and control

Usage: vmtouch [OPTIONS] ... FILES OR DIRECTORIES ...

Options: -t touch pages into memory -e evict pages from memory -l lock pages in physical memory with mlock(2) -L lock pages in physical memory with mlockall(2) -d daemon mode -m max file size to touch -p use the specified portion instead of the entire file -f follow symbolic links -F don't crawl different filesystems -h also count hardlinked copies -i ignores files and directories that match this pattern -I only process files that match this pattern -b get files or directories from the list file -0 in batch mode (-b) separate paths with NUL byte instead of newline -w wait until all pages are locked (only useful together with -d) -P write a pidfile (only useful together with -l or -L) -o output in machine friendly format. 'kv' for key=value pairs. -v verbose -q quiet kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

jroyvde avatar May 07 '24 10:05 jroyvde