Score:1

Force apt or apt-get to return error code on warning

sb flag

apt-get and apt are exiting with 0 instead of an error code when they cant resolve a repository. I'd like to get a non-zero in this case (and for warnings generally).

e.g.

# apt-get update
Err:1 https://mirror.csclub.uwaterloo.ca/ubuntu focal InRelease
  Temporary failure resolving 'mirror.csclub.uwaterloo.ca'
Reading package lists... Done
W: Failed to fetch https://mirror.csclub.uwaterloo.ca/ubuntu/dists/focal/InRelease  Temporary failure resolving 'mirror.csclub.uwaterloo.ca'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Note the output contains Err: and W: so I'd expect this to be an error with non-zero exit code, but it seems like it's just considered to be a warning since the exit code is 0...? Either way I'd like to know how to get an error code instead of zero for the above example and for warnings generally. Yes I could grep for W: or Err: but I'd like the error code if possible.

hr flag
Try this: [apt-get update exit status](https://unix.stackexchange.com/a/653377/65304)
usr30742 avatar
sb flag
`# apt-get update -o APT::Update::Error-Mode=any`, still showed warnings and error but still exited `0`
Score:0
sb flag

You can try apt "replacement": nala

Installation instruction: https://gitlab.com/volian/nala/-/wikis/Installation

Nala have non-zero exit code when some problem occurred, also write problematic part with different color and error part repeat at end of update output...

Running update is same as with apt, but nala have structured output:

sudo nala update

Or if you don't want structured output:

sudo nala update --raw-dpkg

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.