Opened 9 years ago

Last modified 9 months ago

#46229 assigned enhancement

Uninstalling all active ports - are you sure?

Reported by: stuchalk (Stuart Chalk) Owned by: umeshksingla (Umesh Singla)
Priority: Normal Milestone:
Component: base Version: 2.3.3
Keywords: Cc: bitaxis (Nathan Brazil)
Port:

Description

Yesterday I inadvertently ran

"port uninstall active"

when I was trying to run

"port uninstall inactive"

I managed to kill the job before 25% of the installed ports were uninstalled and it has taken me several hours to reinstall all the ports. I was wondering if it would be possible to provide a warning to the user "Are you sure you want to uninstall all active ports?" (or something similar) as I am sure others have made this bone-headed mistake at some point.

Macports is an amazing creation and I thank the developers for their hard work. This additional feature would make it just that much more amazing :)

Stuart

Change History (5)

comment:1 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

The reason this hasn't been done before is that MacPorts up to and including the current release 2.3.3 does not have the capability to ask interactive questions of the user. However, this capability was added for this year's GSoC and is in trunk and will be released as MacPorts 2.4, so it should now be possible to add additional interactive questions, such as the one you suggest.

comment:2 Changed 6 years ago by umeshksingla (Umesh Singla)

Owner: changed from macports-tickets@… to umeshksingla
Status: newassigned

comment:3 Changed 9 months ago by bitaxis (Nathan Brazil)

Not long ago, I made the same mistake as the original author of this ticket. I ended up having to re-install MacPorts and what I needed from scratch. Not catastrophic, at least in my case. But definitely took some time to do.

Would the maintainers please consider adding this enhancement in the near future to avoid silly mistake that at least two people have made?

Thanks!

comment:4 Changed 9 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: bitaxis added

Do you have a suggestion of how to do it? I imagine there are very few people who know MacPorts base well enough to be able to do it. And there are several questions about exactly how this feature should behave.

One problem is that "active" is one of several "pseudo-ports" which expand to a list of ports. I imagine MacPorts base has a procedure that performs this expansion. And then there are other procedures that perform the individual commands like install or uninstall. But the commands like install and uninstall never see that you had typed "active"; they just see the expanded list of ports. It's analogous to wishing there were a warning when you type rm * in the shell. rm can't give you that warning because rm never sees that you typed *; it only sees the list of items that the shell expanded * to. The shell could give you a warning anytime you typed * for any command but that would get tedious in interactive use and would break shell scripts.

Ports and pseudo-ports and other selectors can be combined at will. You can ask MacPorts to do something with ports that are active and not outdated or inactive and name:^lib or outdated and maintainer:ryandesign. Do you want this warning only when the active pseudo-port is used by itself or anytime it is used as part of a selection criteria? Is active the only pseudo-port for which you want this treatment? Does it only apply to the uninstall command or also to others?

One option to implement it could be that we need to keep track of which pseudo-ports were used and make that available to the commands so they can show the warning based on that. Another possibility would be to make the warning appear not based on pseudo-ports but instead based on how many ports the command would act upon—so it could warn if you're trying to uninstall 100 ports, say, regardless whether those 100 ports were specified individually or via some pseudo-port expansion.

Last edited 9 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:5 Changed 9 months ago by bitaxis (Nathan Brazil)

Hi, Ryan.

Thank you for taking the time to respond.

I did not realize I can have an expression when specifying pseudo-ports!

In this case, I am thinking that the user should be asked to confirm an "uninstall" command if "active" is found anywhere in the selector following the command.

When he types that command and presses [Enter], the command will output a list of the expanded ports to show the user what will happen if he answers "yes" to the prompt; if he answers "yes", then proceed to remove all ports specified in the selector

By the way, one of the first things I do with starting to work with any Linux shell is add aliases to always add the -i flag to rm, mv, and cp commands so that I would get a prompt to confirm any such actions, helping me to not accidentally wipe out files unintentionally.

Regards,

Note: See TracTickets for help on using tickets.