Thanks for the participation in this discussion guys. Actually, I wrote the above code in less than a few seconds just as an example. I think we can simply use
sudo snap remove gnome-calculator gnome-character gnome-logs gnome-system-monitor and there’s no need for the above codes that’s pretty much useless. I’m trying to demo how this error “not found” detection is useful to know instead of simply saying “yeah, I can’t find this package locally and I don’t think this remove command is a mistake”. I can’t explain it in a better way if we use the 1 liner above, it will show a “conflicting” error message log while another snapd seed is in progress hence, the loop in my previous example.
@ijohnson I don’t get what
snap list $THE_SNAP is and how that can return 1 if it isn’t installed locally, where did you get that variable from anyway?
@chipaca As I mentioned above, you gave snapd a command to remove foo, but it couldn’t find it hence it thinks it did not find an error but I’m fine by that ideology. If so, how can you know that it isn’t installed at the first place? Like the above
sudo apt purge, if it can’t find the package installed locally it will tell you an error exit code instead so we know for sure that package isn’t available and nothing can be removed hence the purge/remove command is invalid or “error” – or “soft-error” that’s rather subjective.
Also, your suggestion is the same as the one-liner code I wrote in reply to @ijohnson above. It works just fine but I don’t like the “conflicting” message log, not sure whether the process is simultaneously or queue but why that conflicting messages are even shown to begin with. I need to display the removal process notifcation individually hence the loop…
ogra I’m not so sure about resource hog, but I wrote the above codes to setup a few of my “quite powerful i7” home PCs for a custom Ubuntu installation with some other GNOME tweaks, dynamic wallpapers, etc. to make my life a little easy and removing those pre-installed snap apps are just a small part of the process. I wanted to create my own custom ISO but ended up creating this script instead since sometimes, I want a different setup and ask the end users using some zenity window for customization…
Thanks again! I appreciate your feedback.