-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
command line separation with -- broken in several context #1695
Comments
I agree (I think) that in all of these cases, the |
Hmm, we have -- in use in git, also in kubectl. For those to work I guess they need -- as an arg no? |
Regarding scenario 2 (file name without babashka/src/babashka/main.clj Line 751 in 5cd2b9d
-- ) into :command-line-args .The first idea that comes to mind is doing a recur thing sort of like how subcommands are handled, except maybe assoc'ing :file onto opts-map, and recurring with (next options) and the updated opts-map. I'm not too sure yet if that has unwanted consequences, because parse-file-opt is called from two places, so tweaking that could be problematic.
There's another potential scenario, which is a file that doesn't exist ( babashka/src/babashka/main.clj Lines 680 to 684 in 5cd2b9d
I think this is actually what's happening in scenario 4, because if I'm working this out correctly, babashka/src/babashka/main.clj Lines 614 to 618 in 5cd2b9d
means that when --repl (or repl which gets re-written to --repl ), this code consumes both --repl and the option after it, which in case of scenario 4 means the -- is getting swallowed. Adding a throw-away option eliminates the file not found error:
$ bb repl -- asdf sdf
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: File does not exist: asdf
$ bb repl junk -- asdf sdf
Babashka v1.3.190 REPL
... The fact that babashka/src/babashka/main.clj Line 1048 in 5cd2b9d
|
@bobisageek If you want to work on a PR to address (some of) these, you're welcome to do so. |
I'm trying to think through some of the possibilities where a change here could change existing behavior in an undesired way. There are a couple existing tests babashka/test/babashka/main_test.clj Lines 77 to 78 in 5cd2b9d
that I think sort of imply "if the first argument is a file (with no -f), then everything afterwards is an arg to the file". Put a different way, 'fixing' scenario 2 might break those existing tests (and obviously, scripts that rely on that). If we sort of flip scenario 2 around to match those tests: ; this is the existing test - pass a file without `-f` and we don't process any more args...
(main/main "test-resources/script_with_overlapping_opts.clj" "--version")
("--version") ; this is the prn of *command-line-args*
=> 0 ;exit code
; but if we use `-f`, then subsequent args are still processed as potential args to `bb`
(main/main "-f" "test-resources/script_with_overlapping_opts.clj" "--version")
babashka v1.3.191-SNAPSHOT ; just print the version text, script effectively does nothing
=> 0 So, as a solution that I think would preserve that existing behavior, we could special-case that if we're 'inferring' a file (as opposed to being told with |
OK, we can ignore changing |
Somehow the docker step on master started acting up after merging this. Not sure if it's related. |
The Github action 'docker' looks like it's disabled. Is there a different docker step I should be looking at? |
CircleCI |
Oh I see:
This has nothing to do with your PR. |
Given a script
cmd.clj
:$ cat /tmp/cmd.clj (prn *command-line-args*)
The following should not have the hyphen probably?
The text was updated successfully, but these errors were encountered: