Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#23366 closed defect (fixed)

Clojure "clj" scripts mess up command line arguments

Reported by: jsg8pitt@… Owned by: mdippery@…
Priority: Normal Milestone:
Component: ports Version: 1.8.2
Keywords: haspatch Cc:
Port: clojure

Description

clj myscript.clj foo bar baz should have *command-line-args* internally bound to ("foo" "bar" "baz"). However, because of the implementation of the clj wrapper scripts, it ends up being bound to ("myscript.clj" "--" "foo" "bar" "baz").

This happens because $* is being used to execute the actual clojure command. However, that repeats the name of the script which was used. Preceding the invocation of clojure with a call to shift will yank the script name out of the arguments.

I can't tell what the purpose of "--" is, and it sort of strikes me that if I need that argument, then I should pass it myself, but I don't really know.

Patch attached.

Attachments (2)

clj.patch (329 bytes) - added by jsg8pitt@… 14 years ago.
Fixes the behavior of the command line args in the clojure shell wrapper.
clj.2.patch (3.0 KB) - added by mdippery@… 14 years ago.
New Clojure patch: Fixes issues and removes readline variant (in favor of rlwrap)

Download all attachments as: .zip

Change History (15)

Changed 14 years ago by jsg8pitt@…

Attachment: clj.patch added

Fixes the behavior of the command line args in the clojure shell wrapper.

comment:1 Changed 14 years ago by jmroot (Joshua Root)

Keywords: haspatch added; clojure clj removed
Owner: changed from macports-tickets@… to mdippery@…

comment:2 Changed 14 years ago by mdippery@…

Looks good to commit.

comment:3 Changed 14 years ago by jsg8pitt@…

So, could someone commit it then?

comment:4 Changed 14 years ago by alex.taggart@…

The patch is not correct since it leaves the scriptname as the first element in the list. Just get rid of the scriptname altogether:

else
  exec java -classpath $cp $cljclass $*
fi

comment:5 Changed 14 years ago by mdippery@…

Okay, I've written up a new patch which should fix this latest issue.

I also removed the jline variants since it's functionally the same as the rlwrap variant, but the rlwrap variant does it better anyway, and I was getting tired of maintaining *three* nearly identical scripts.

Changed 14 years ago by mdippery@…

Attachment: clj.2.patch added

New Clojure patch: Fixes issues and removes readline variant (in favor of rlwrap)

comment:6 Changed 14 years ago by alex.taggart@…

Is this fix going to be applied anytime soon?

As of today:

$ tail test.clj (println *command-line-args*) $ clj test.clj foo bar (-- test.clj foo bar)

Should be (foo bar)

comment:7 in reply to:  6 Changed 14 years ago by mdippery@…

Replying to alex.taggart@…:

Is this fix going to be applied anytime soon?

As of today:

$ tail test.clj (println *command-line-args*) $ clj test.clj foo bar (-- test.clj foo bar)

Should be (foo bar)

Is that output with or without the latest patches?

comment:8 Changed 14 years ago by alex.taggart@…

Is this port abandoned? Can we transfer control to someone who will actually apply the fix?

This bug has been languishing here, unpatched, for months. Every time I try to encourage coworkers to try out clojure on their macs, I have to "fix" this bug, which makes the community seem like a collection of illiterates. This is not a hard bug to test.

$ echo "(println *command-line-args*)" > test.clj
$ clj test.clj foo bar
(-- test.clj foo bar)

Where the correct output should be (foo bar).

If you're going to take the one good name for a clojure port at least maintain the damn thing.

comment:9 in reply to:  8 Changed 14 years ago by mdippery@…

Replying to alex.taggart@…:

Is this port abandoned? Can we transfer control to someone who will actually apply the fix?

I've authorized the patch. I don't have commit access to the MacPorts SVN repo.

comment:10 Changed 14 years ago by jsg8pitt@…

Do you need to do something in particular then to get the patch committed?

I see that past changes to the Portfile have been made in the past by ryandesign, macsforever2000, blb and jmr. Can one of them help here?

comment:11 Changed 14 years ago by mdippery@…

I'll ping the mailing list.

comment:12 Changed 14 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: newclosed

Committed in r69628.

comment:13 Changed 14 years ago by raimue (Rainer Müller)

Fixed conflict with non-existing variant in r69629.

Note: See TracTickets for help on using tickets.