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

[Linux] Fix "Unexpected argument '&'" error when trying to open URL #2490

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

NotHyper-474
Copy link

@NotHyper-474 NotHyper-474 commented May 13, 2024

Fixes the background thingie not being passed properly to the command line due to how Sys works, which causes an error and prevents the link from being opened

Could be something with my system for all I know, not sure if being on Ubuntu WSL2 changes how the command behaves.
If anyone else also compiles in Linux (no WSL) please confirm if this error happens to you too.

Edit: I tested this through native Ubuntu and also got the same error, so not related to WSL, unless it's related to Ubuntu in general.
Edit 2: This error is caused by how Haxe's Sys.command appends the arguments to the console, encasing them with single quotes. So the original code would cause the command to be xdg-open 'https:/link.here' '&' which makes xdg think that & is an argument, so not related to any Linux distro.

@gamerbross
Copy link
Contributor

using string interpolation should be more readable

Sys.command('/usr/bin/xdg-open $targetUrl &');

@NotHyper-474
Copy link
Author

NotHyper-474 commented May 13, 2024

Alright, thanks, gonna do that now.

@NotHyper-474 NotHyper-474 changed the title [Linux] Fix "Invalid argument '&'" error when trying to open URL [Linux] Fix "Unexpected argument '&'" error when trying to open URL May 14, 2024
@ninjamuffin99
Copy link
Member

if someone can show/record some before/after of this change, that would be very helpful :)
also im linux noob still, this is consistent across distros ? i was always curious about that command...

@NotHyper-474
Copy link
Author

xdg-open is part of the xdg-utils package, which generally is installed by default in distros with a desktop manager, so it's not guaranteed to work in every single distro, but there doesn't seem to exist a better alternative.

And here's the before and after, tested in Kali Linux (WSL)

before.mp4
after.mp4

@ninjamuffin99
Copy link
Member

very nice !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants