Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gr225 opened this issue Sep 17, 2022 · 8 comments
Open

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

gr225 opened this issue Sep 17, 2022 · 8 comments
Assignees
Labels
Bug Can't replicate It's not possible to replicate the issue Need To Investigate

Comments

@gr225
Copy link

gr225 commented Sep 17, 2022

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

@mirkobrombin mirkobrombin added this to the 2022.9.28 milestone Sep 19, 2022
@mirkobrombin mirkobrombin moved this to Todo 🎈 in Brescia Sep 19, 2022
@mirkobrombin
Copy link
Member

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 mirkobrombin added the Can't replicate It's not possible to replicate the issue label Sep 25, 2022
@mirkobrombin mirkobrombin removed this from the 2022.9.28 milestone Sep 25, 2022
@gr225
Copy link
Author

gr225 commented Sep 25, 2022

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
Copy link
Author

gr225 commented Oct 20, 2022

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?

@ebaldino
Copy link

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...

@gr225
Copy link
Author

gr225 commented Oct 22, 2022

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.

@ebaldino
Copy link

ebaldino commented Oct 22, 2022

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.

@psydvl
Copy link
Contributor

psydvl commented Dec 13, 2022

I hope will be partially solved in next release via #2342
Partially, because there is still problem with escaping &, I'm working on in #2361

@jroyvde
Copy link

jroyvde commented May 7, 2024

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Can't replicate It's not possible to replicate the issue Need To Investigate
Projects
No open projects
Status: Todo 🎈
Development

No branches or pull requests

5 participants