HereInPlainSight / gshade_installer

GShade Installer / Updater Bash Script for Linux
GNU General Public License v3.0
59 stars 18 forks source link

printf: `D': invalid format character #23

Closed schumar closed 1 year ago

schumar commented 1 year ago
$ ./gshade_installer.sh update
Restoring any applicable GShade.ini settings...  ./gshade_installer.sh: line 227: printf: `D': invalid format character
Completed!
GShade-v4.0.0 installed.

$ git describe --all --long
heads/master-0-g6559b8a

It seems that line 227

  confFile=$(printf "$(<$iniFile)")

assumes that the content of $iniFile is a format-string?

HereInPlainSight commented 1 year ago

That was very careless of me, I'm so sorry. That line should have been confFile=$(printf "%s" "$(<$iniFile)"). The lack of "%s" was making it look inside the GShade.ini file for formatting strings -- not an issue until some %'s were added to the 4.0 version of the config file, but it never should've been missing the explicit format string in the first place.

Thankfully this would only have lost someone's Language setting (if it was something other than English in the first place), but that was still a big error on my part. Thank you for the report.

schumar commented 1 year ago

Thanks for the quick fix!

What helps me a lot when writing shell-scripts is ShellCheck (apt install shellcheck).

It has a lot of common errors it looks out for, e.g. it correctly complained

In gshade_installer.sh line 227:
  confFile=$(printf "$(<$iniFile)")
                    ^------------^ SC2059: Don't use variables in the printf format string. Use printf '..%s..' "$foo".

(it also has some false positives, though)

HereInPlainSight commented 1 year ago

Thank you -- I actually used to use ShellCheck, but it used to kick back so many false positives, I fell out of the habit. I have to push a new commit to fix a bug with opengl games -- not sure if I'll finish that today or not -- after that I'll see about trying to go over the script with shellcheck again.