Opened 10 years ago
Last modified 20 months ago
#11893 assigned bug
When a shell script is the handling application for a mimetype, registrar does not propagate arguments to it
Reported by: | waddlesplash | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Applications/Tracker | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
I'm currently working on a launcher for Jar files. Everything currently works, except when Registrar launches the script because I double-click on a file in Tracker or use open
, it doesn't pass the filename as an argument, even with B_ARGV_ONLY
in the app_flags
.
The script and RDEF are attached. Set them up with:
chmod +x hjava rc hjava.rdef resattr -o hjava hjava.rsrc
(Note that resattr
was not included in the build until hrev48852, so prior to that you'll have to compile it yourself.)
Attachments (2)
Change History (14)
by , 10 years ago
Attachment: | hjava.rdef added |
---|
by , 10 years ago
comment:1 by , 10 years ago
Component: | Servers/registrar → Applications/Tracker |
---|---|
Owner: | changed from | to
comment:2 by , 10 years ago
Ah, makes sense. I did look at BRoster::Launch but I saw no reason why it wouldn't work...
follow-up: 6 comment:3 by , 10 years ago
Looking at the BRoster
code this seems intentional (and also applies to regular non-BApplication executables, not just scripts). If no additional arguments (argc, argv) are passed to BRoster::Launch()
then it won't include the target file path in the argument vector.
It will send the file ref later in a message. It will try to send the message even if the app has the B_ARGV_ONLY
flag — which seems to go against the definition given in the Be Book. Is this the BeOS behaviour, or a mistake?
comment:4 by , 10 years ago
At least the BRoster::Launch()
unit tests for the B_MULTIPLE_LAUNCH | B_ARGV_ONLY
cases suggest (here and here) that main()
args are actually expected. At a quick glance, the argv cases are exercised by the test methods LaunchTester::LaunchTestC3(), LaunchTester::LaunchTestF8(), and LaunchTester::LaunchTestF9().
The tests were modelled to verify the BeOS R5 behavior and Haiku's app kit classes were written against the tests. It would be interesting to run the tests against the current Haiku.
comment:5 by , 10 years ago
After some battling with the unit tests it seems that the argv is not expected to contain the file path if no additional args are passed. See http://cgit.haiku-os.org/haiku/tree/src/tests/kits/app/broster/LaunchTesterHelper.cpp#n426.
I'm curious if this is indeed the behaviour on BeOS for a B_ARGV_ONLY
app, because it seems that a B_ARGV_ONLY
app would have no other way to receive the target file in that case.
A few of the tests were also broken because the BMessage::ReturnAddress()
of the messages sent to the launch context would refer to the launch context itself. On the test app side, it makes a copy of the RefsReceived
message, and this also ends up copying the reply-to address of the message. If the tests pass under BeOS, that would suggest this behaviour is also wrong.
comment:6 by , 10 years ago
comment:7 by , 10 years ago
Unfortunately not — this concerns the BRoster launching behaviour rather than BApplication's silent-relaunch.
comment:8 by , 10 years ago
After some testing (thanks to Diver) it seems that this does indeed match the BeOS behaviour.
Is there a strong reason to keep this behaviour? None of our in-tree apps that use B_ARGV_ONLY
expect to be launched as the handler of a file -- so they would not be affected by such a change.
comment:9 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 6 years ago
Interestingly, it seems that as long as the passed ref is indeed a document, it gets put into argv anyway: http://xref.plausible.coop/source/xref/haiku/src/kits/app/Roster.cpp#518 -- http://xref.plausible.coop/source/xref/haiku/src/kits/app/Roster.cpp#1893. So I'm not entirely sure what's going on here.
comment:11 by , 20 months ago
It looks like I've encountered this bug now and its stopping me using mpv as my default video player under Tracker.
comment:12 by , 20 months ago
mpv is a gui application and should not use this flag. It will mark that the application does not accept BMessages and break other functionality like screenshoting.
If the script can be registered as an application -- which surprises me a bit, but well ... -- the registrar isn't involved in its execution. The code you're looking for is generally in
BRoster::Launch()
, but I believe Tracker only gets the handling application fromBRoster
and does the launching itself.