Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive of 2059 and 2005 when combining printf and gettext #1098

Open
2 of 4 tasks
nihilus opened this issue Jan 20, 2018 · 2 comments
Open
2 of 4 tasks

False positive of 2059 and 2005 when combining printf and gettext #1098

nihilus opened this issue Jan 20, 2018 · 2 comments

Comments

@nihilus
Copy link

nihilus commented Jan 20, 2018

For bugs

  • Rule Id (if any, e.g. SC1000):
  • My shellcheck version (shellcheck --version or "online"):
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/
SIGSTRENGTH="10"
printf "$(gettext "%d%%")" "$((SIGSTRENGTH))"
echo "$(gettext "Unknown")"

Here's what shellcheck currently says:

Gives 2059 and 2005.

Here's what I wanted or expected to see:

Nothing, since this is the way to use 'gettext' IMHO.

@nihilus nihilus changed the title Flase positive of 2059 and 2005 when combining printf and gettext False positive of 2059 and 2005 when combining printf and gettext Jan 21, 2018
@deryni
Copy link

deryni commented Jan 25, 2018

About SC2005, if you have other contents in the string passed to echo then it shouldn't trigger and if you don't have other contents in the string passed to echo then why is SC2005 not correct? Do you need to use echo "$(gettext "Unknown")" instead of just gettext "Unknown" for some reason there to get the output you expect? (Though perhaps you need gettext -s "Unknown" there instead?)

@nihilus
Copy link
Author

nihilus commented Mar 5, 2018

IIRC there was a reason for using echo; there is an issue with xgettext for extraction when using commandline switches to gettext: https://stackoverflow.com/questions/47896058/extracting-strings-from-shell-gettext-s-using-xgettext

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

No branches or pull requests

2 participants