rjbs / Dist-Zilla

scary tools for building CPAN distributions
http://dzil.org/
186 stars 152 forks source link

listdeps --cpanm-versions returns the version number not in the documented format #725

Open abraxxa opened 6 months ago

abraxxa commented 6 months ago

This came up in https://github.com/skaji/cpm/issues/245. https://metacpan.org/pod/cpanm#COMMANDS documents the version without any quoting, https://metacpan.org/pod/CPAN::Meta::Spec neither. cpm fails if the version is surrounded by quotes as dzil listdeps --cpanm-versions returns.

karenetheridge commented 6 months ago

cpanm does provide one example using quotes, suggesting that quotes are supported everywhere: cpanm Plack~">= 1.0000, < 2.0000"

karenetheridge commented 6 months ago

Two actually: it also says: ...while @ pins the exact version, and is a shortcut for ~"== VERSION".

Does cpm support these two literal examples that cpanm references?

Grinnz commented 6 months ago

cpanm's example using quotes is a shell command, and the shell will remove the quotes as part of its parsing; they are in the example because they are required to pass it as a single shell argument.

karenetheridge commented 6 months ago

Interesting, I would have thought that embedded quotes would be preserved by the shell, but indeed they aren't:

perl -MData::Dumper -wle'print "got args ", Dumper(\@ARGV)' cpanm Plack~">= 1.0000, < 2.0000"
got args $VAR1 = [
          'cpanm',
          'Plack~>= 1.0000, < 2.0000'
        ];

So, why isn't cpm also receiving the arguments with the quotes stripped? If the dzil output is piped to cpm just as it is to cpanm, everything should work fine. Is cpm being invoked differently?

Grinnz commented 6 months ago

As a point of comparison, in my installdeps command I must form the argument without quotes because it is then quoted as a shell argument, which would preserve the quotes when passed through the shell. https://github.com/Grinnz/Dist-Zilla-App-Command-installdeps/blob/master/lib/Dist/Zilla/App/Command/installdeps.pm#L103

abraxxa commented 6 months ago

So, why isn't cpm also receiving the arguments with the quotes stripped? If the dzil output is piped to cpm just as it is to cpanm, everything should work fine. Is cpm being invoked differently?

When it is piped to xargs the quotes are removed, when piped to cpm - directly they seem to be kept. But in the later case no shell is involved...