amazon-linux-2023 icon indicating copy to clipboard operation
amazon-linux-2023 copied to clipboard

dnf check-release-update output not stdout

Open ring-pete opened this issue 2 years ago • 5 comments

Description I am trying to automate detection of new Amazon Linux2023 versions being available using dnf check-release-update and it looks like the output of that command is not sent to stdout. I would assume that I could invoke the command, then assign a variable to the output of it. While text does print to the console, variable assignment or redirection does not work as expected.

To Reproduce Steps to reproduce the behavior:

  1. Run an Amazon Linux 2023 system
  2. Login as any standard user, ec2-user for example
  3. Execute the following commands:
$ echo $SHELL
/bin/bash
$ cat /etc/amazon-linux-release
Amazon Linux release 2023 (Amazon Linux)
$ VERSION=$(dnf check-release-update --latest-only --version-only)
2023.2.20231030
$ echo $VERSION

$ dnf check-release-update --latest-only --version-only > /tmp/version
2023.2.20231030
$ cat /tmp/version

Expected behavior I would expect the check-release-update plugin to allow redirection of stdout so that it can be assigned to a variable, or redirected to a file, etc. as any other standard Unix utility would function.

ring-pete avatar Nov 09 '23 00:11 ring-pete

It's outputing to stderr not stdout, you can catch it with 2> instead of > for redirection. As to wether this is a desirable behaviour, I'll let others comment

ozbenh avatar Nov 09 '23 22:11 ozbenh

Thanks that's super helpful, I can confirm this works:

$ U=$(dnf check-release-update --latest-only --version-only 2>&1)
$ echo $U
2023.2.20231030
$

I am strongly in the "this is undesirable behavior camp" - if we are unable to correct this antipattern then having a note in the help output would be a huge help to others.

ring-pete avatar Nov 09 '23 23:11 ring-pete

Yeah, this seems less than ideal behavior here.

stewartsmith avatar Nov 10 '23 18:11 stewartsmith

+1, we should fix this.

nmeyerhans avatar Nov 13 '23 00:11 nmeyerhans

A bit late, but it would be nice if the plugin returned 100 like dnf check-release if there are updates available.

phongn avatar Jul 31 '25 17:07 phongn