Using absolute file path doesn't work in an unix like environment.
schorsch3000 opened this issue · 7 comments
Since Mospeed is written in Java it works fine unter Linux or OSX.
The arg parser is just a little bit too easy.
Around this line here:
Every argument starting with a -
or a /
makes is a parameter, the first argument not starting with one of them ist da source file.
This results in 2 problems:
a Filename cannot start with -
You can't use an absolute File path like tmp/test.bas
Maybe just make the last argument the sourcefile?
Or use just -
as a parameter prefix and make --
stop parameter parsing.
One of those are implemented by most cli tools.
I'm not firm in Java, but at least the first suggestion seems to be easy.
Just pop the last element, set it as source file and don't set a sourcefile in the loop.
PS: there is no way to see which version my mospeed is, maybe also add a /version?
Thanks for your work
Schorsch3000
Turns out, i'm not using a release version but a checked out version from master
.
i can confirm this behavior on the current master
as well.
I don't really like the idea of using the last parameter as source. And I can happily live with not allowing files that start with a "-"...
But I don't get the second problem that you mentioned:
You can't use an absolute File path like tmp/test.bas
Why can't I?
sorry, that's a typo.
should be /tmp/test.bas
that's because everything with a / is a parameter.
using -
or --
instead of /
should be fine.
sure, you can't access a file named -foo.bas
directly, but ./-foo.bas
works fine.
I see...I guess I could check first, if /whatever/some/file.bas actually is a file and if not, handle it as a parameter...and do the same for -. That's a bit...hacky, I guess. But then again, the whole MOSpeedCL-class is...I'll give it a try...
The most used way to do that in the unix was is to go from left to right, parse the parameters by the prefixed - or/and -- and stop parameter parsing if there is a --
by it self.
in this case i guess replacing / by - or checking if that is a file before using it as a parameter is going to be fine.
Nobody is going to have a file named /deadcodeopt=true
or -deadcodeopt=true
which would be an edgecase.
Also both cases would have a workaround:
//deadcodeopt=true
./-deadcodeopt=true
I commited this "fix". Can you give it a try?
yep, this works fine, thanks 👍