bash-tpl icon indicating copy to clipboard operation
bash-tpl copied to clipboard

fix!: Use %b in generated printf statements (vs %s)

Open TekWizely opened this issue 1 year ago • 4 comments

closes #25

Looks like I was supposed to be using %b all along:

  • https://www.unix.com/man-page/posix/1posix/printf/

... An additional conversion specifier character, b , shall be supported as follows. The argument shall be taken to be a string that may contain backslash-escape sequences

It appears that many shells treat %s and %b similarly, which is likely why I didn't discover the issue earlier.

As a posix printf standard, this should just be an improvement, correcting behavior for shells like DASH.


cc: @0xEAB lemme know if you have time to give this a test drive.

TekWizely avatar Jun 24 '24 02:06 TekWizely

cat bug.txt

RUN apt-get update && \
	apt-get -y install --no-install-recommends

./bash-tpl_patched bug.txt | /bin/dash

RUN apt-get update && \
$	apt-get -y install --no-install-recommends

0xEAB avatar Jun 25 '24 19:06 0xEAB

Closing this MR as its not a working solution to the problem ...

TekWizely avatar Jun 25 '24 21:06 TekWizely

@0xEAB I've re-opened this MR after having a chance to do some research - I've implemented a printf %b compatible escape function which I hope doesn't break other users once its released :)

I'd appreciate if you had a had a chance to give it another try!

TekWizely avatar Jul 01 '24 01:07 TekWizely

Works for me.

0xEAB avatar Jul 01 '24 02:07 0xEAB