Skip to content

printf: Fixing incorrect exit code when passing invalid value to %x#5543

Merged
tertsdiepraam merged 2 commits intouutils:mainfrom
pawelngei:printf-x-incorrect-exit-code-when-invalid-value
Nov 15, 2023
Merged

printf: Fixing incorrect exit code when passing invalid value to %x#5543
tertsdiepraam merged 2 commits intouutils:mainfrom
pawelngei:printf-x-incorrect-exit-code-when-invalid-value

Conversation

@pawelngei
Copy link
Copy Markdown
Contributor

Fixes #5536 by changing the warning called from the intf module and adding an appropriate exit code.

Created a test to confirm the behavior.

Before:

./target/debug/coreutils printf %x %194 > /dev/null
echo $? 

returns:

printf: '%194': value not completely converted
0

After:

printf: %194: expected a numeric value
1

@pawelngei
Copy link
Copy Markdown
Contributor Author

pawelngei commented Nov 15, 2023

Ah, I only now realized that the ' quotes are missing. Let me add them ;)

EDIT: Checked on main, there are no quotes in either warning, so I guess the PR is complete.

Copy link
Copy Markdown
Collaborator

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this is the correct solution for this version of the code! Nice work!

The quotes we can fix somewhere else, because I think they should probably be part of all messages.

@tertsdiepraam tertsdiepraam merged commit da84583 into uutils:main Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

printf: incorrect exit code when passing invalid value to %x

2 participants