Opened 16 years ago

Closed 15 years ago

Last modified 14 years ago

#14458 closed enhancement (wontfix)

port lint should issue error if port uses deprecated "exit" or "cd" commands

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.6.0
Keywords: Cc:
Port:

Description

port lint should issue an error if a port uses the "exit" command which was removed by MacPorts 1.6 or the "cd" command which will be removed by MacPorts 1.7. Care should be taken in the implementation because port lint should only complain if these commands are being used as tcl commands, but not if they appear in a (possibly multiline) string or comment.

Change History (5)

comment:1 Changed 16 years ago by raimue (Rainer Müller)

Not that easy to implement, I think. It would require to check full Tcl syntax. For example:

set cd foo   # valid
set [cd foo] # invalid
cd foo       # invalid
set exit 1   # valid
exit 1       # invalid
do; exit 1   # invalid
do && exit 1 # invalid

But this can also be complexer, as you can create variable functions:

set foo exit
$foo 1       # is now equivalent to `exit 1'

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

While it's true that someone could do that, in fact I don't think anybody does. I'm not trying to catch people who are trying to be tricky; I'm trying to catch ports where people simply use the exit or cd commands as normal. exit was removed a long time ago, but a new port was just committed containing this nonfunctional command. And people are still adding new ports using the cd command, perhaps because they don't know it's going away Real Soon Now.

If we can't use the Tcl parser somehow to detect this properly, I'd settle for the line-by-line parser that we have now. It would have to have flags to track whether the line is inside a multiline string or a continuation of the line above. And if it's neither (meaning it is a command line and it's not a continuation of a previous line) then we would look if the first word is "exit" or "cd".

One special case would be when the command appears on the same line as the opening curly brace for the phase; this happens quite a lot, like in the perforce port which has a line:

destroot	{ cd ${worksrcpath}

But even implementing the feature without support for this special case would be an improvement over what we have now.

comment:3 Changed 16 years ago by afb@…

Hmm, port lint only does a two-pass static analysis at the moment (once to check the file, like for encoding and location and once to parse the file syntax and read the basic metadata variables)

Things like deprecated tcl commands should be evident from the trial build of the port, so I'm not sure whether they need to be checked with lint ? (since that would mean having to parse/run stuff)

comment:4 Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: wontfix
Status: newclosed

Not worth it, especially now that both exit and cd will cause problems when used, since MacPorts 1.7.0 (without the cd command) has been released.

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

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