Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#57003 closed defect (fixed)

port info order of fields is unexpected

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: Kurt Hindenburg <kurt.hindenburg@…>
Priority: Normal Milestone: MacPorts 2.6.0
Component: base Version: 2.5.99
Keywords: Cc: kurthindenburg (Kurt Hindenburg)
Port:

Description

The order in which port info outputs fields is consistent, for a particular set of flags, but is unexpected. The output order does not match the order of the flags, yet it changes if I change the order of the flags:

$ port info --name --epoch --revision --version py35-tkinter
version: 3.5.6
revision: 0
epoch: 20170810
name: py35-tkinter
$ port info --name --revision --version --epoch py35-tkinter
version: 3.5.6
epoch: 20170810
revision: 0
name: py35-tkinter

What's going on here? Are the flags perhaps being stored in an unordered collection, and the order in which we process them depends on the order in which Tcl happens to store them?

We should either make the output the same regardless of the order in which the flags are specified (alphabetical order, for example), or (my preference) output the fields in the order in which the flags were specified on the command line. (As an addendum, this might mean we want to add the ability to output the same field more than once: port info --name --name currently outputs the name only once.)

Either change may break scripts that relied on the current peculiar order of output, so we should probably not make the change in a bugfix release of MacPorts, but in a feature release.

Change History (6)

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

The list of fields to print is generated with [array names options ports_info_*]. macports-base/src/port/port.tcl#L2097

comment:2 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Ok, Tcl tutorial confirms that array names doesn't return results in a particular order.

comment:3 Changed 6 years ago by kurthindenburg (Kurt Hindenburg)

Cc: kurthindenburg added

Do we just want to use (alphabetic) lsort?

not tested: [lsort [array names options ports_info_*]]

comment:4 Changed 6 years ago by kurthindenburg (Kurt Hindenburg)

This seems to work as Ryan requested - open to suggestions on how to do this better

https://github.com/macports/macports-base/pull/103

comment:5 Changed 5 years ago by Kurt Hindenburg <kurt.hindenburg@…>

Owner: set to Kurt Hindenburg <kurt.hindenburg@…>
Resolution: fixed
Status: newclosed

In e115b59055a4e5ef7c669990cf86dd39be7ab9b3/macports-base (master):

port-info: output fields in the order given on the command line (https://github.com/macports/macports-base/pull/103)

  • port-info: output fields in the order given on the command line

Currently due to the use of 'array names', the output of
'port info --multiple-fields' are displayed in a random order.
Now, the fields are kept in a list which preserves their order they
were given on the command line.
This has the effect of also allowing duplicate fields to be displayed.

Also, the order of arguments given on the command line are available
for any action (not just info).

Closes: #57003

comment:6 Changed 5 years ago by jmroot (Joshua Root)

Milestone: MacPorts 2.6.0
Note: See TracTickets for help on using tickets.