TekWizely / bash-tpl

A smart, lightweight shell script templating engine, written in Bash
MIT License
65 stars 4 forks source link

fix!: Use %b (and Compatible Escaping) for Quoted strings #26

Closed TekWizely closed 2 days ago

TekWizely commented 2 months ago

closes #25

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

... 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.

0xEAB commented 2 months ago

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
TekWizely commented 2 months ago

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

TekWizely commented 2 months ago

@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!

0xEAB commented 2 months ago

Works for me.