-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
"Error Expected one or zero arguments." when passing program arguments via "dub --single" without --
#2980
Comments
Note that there is already a special mode for shebang lines where you just run |
Unfortunately that way of running programs via Dub is slightly more buggy: #2672
There are no ambiguities. I don't mean to be disrespectful, but that's what pretty much every other program out there is doing, while Dub is doing something else. I think you should have some of the above enumerated programs on your computer already and can verify that they all behave consistently with each other and inconsistently with Dub? |
Doesn't the bug affect the
Right now it does the opposite, hence the ambiguity ;) But seriously, this can easily break existing scripts in non-trivial ways (and I'm pretty sure I personally have some that will be broken, because I have something like I'd have to do some research, but I've definitely seen the |
Oops, you're right!
Yes, it would be a breaking change. I'm hoping we could still do this with a deprecation cycle...
Not sure about |
This is what I mean: https://nodejs.org/api/cli.html#command-line-api I don't know, there are clearly different ways in which this has been implemented in popular tools and the current way is clearly not that unusual. |
$ cat test.js
console.log(process.argv);
$ node test.js -v
[
'/usr/bin/node',
'/home/vladimir/tmp/2024-12-21-scratch/14:33:03/test.js',
'-v'
] It behaves like the tools I mentioned above.
No: $ npx http-server -v
v14.1.1
$ npx -v http-server
10.9.0
I think Cargo's Syntax-wise, for Cargo, the package name is an argument to the
Sorry, but I need to push back on this. I believe that you haven't looked at this closely enough. |
System information
Bug Description
Dub seems to require
--
to pass arguments to programs when invoked via--single
. I.e., this works:$ dub --single program.d -- my-argument
and this doesn't:
$ dub --single program.d my-argument
We should use
Config.stopOnFirstNonOption
or equivalent and pass everything after the program name to the program, without parsing it ourselves.This will align Dub with most other tools that need to run other programs, such as GNU
env
,rdmd
,dmd -run
, anddocker run
(which uses containers instead of programs).It will also allow using
dub --single
in shebang lines. Because the--
must come after the program name, it is not possible to specify it in the shebang line.The only reason why we would want to require
--
is for situations where the name of the program itself (!) could be parsed as an option, e.g. to run a file called-program.d
. This also aligns with how many other programs (such as GNU coreutils) use the--
argument.The text was updated successfully, but these errors were encountered: