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

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

NotHyper-474
Copy link
Contributor

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

@ninjamuffin99 ninjamuffin99 added the status: needs clarification Requires more info from the author. label May 15, 2024
@NotHyper-474
Copy link
Contributor 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 ninjamuffin99 added this to the 0.4.0 milestone May 24, 2024
@ninjamuffin99 ninjamuffin99 added reviewing-internally and removed status: needs clarification Requires more info from the author. labels May 24, 2024
@ninjamuffin99
Copy link
Member

very nice !

@EliteMasterEric EliteMasterEric removed this from the 0.4.0 milestone Jun 7, 2024
@EliteMasterEric EliteMasterEric merged commit 3aa3007 into FunkinCrew:develop Jun 7, 2024
@NotHyper-474 NotHyper-474 deleted the fix-url-open branch June 7, 2024 23:59
@EliteMasterEric EliteMasterEric added this to the 0.4.0 milestone Jul 12, 2024
@Hundrec Hundrec added type: minor bug Involves a minor bug or issue. status: accepted PR was approved for contribution. If it's not already merged, it may be merged on a private branch. size: small A small pull request with 10 or fewer changes. pr: haxe PR modifies game code. labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: haxe PR modifies game code. size: small A small pull request with 10 or fewer changes. status: accepted PR was approved for contribution. If it's not already merged, it may be merged on a private branch. type: minor bug Involves a minor bug or issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants