sagiegurari / duckscript

Simple, extendable and embeddable scripting language.
https://sagiegurari.github.io/duckscript
Apache License 2.0
508 stars 49 forks source link

`printf` feature request #439

Open SamuelMarks opened 3 weeks ago

SamuelMarks commented 3 weeks ago

Feature Description

It would be great to have a printf. I'm doing fancy escaping stuff where I want to evaluate a variable and quote it so PostgreSQL can execute the query correctly.

Describe The Solution You'd Like

At least basic printf syntax

Code Sample

printf '%s \'%s\' "%s"' 'foo haz' "${can}" bar

Alternatives like std::string::Concat are unfriendly:

$ duck
a = set 5
c = concat '"' ${a} '"'
echo ${c}
'"'5'"'
q = set '
e = concat ${q} ${a} ${q}
echo ${e}
'5'
sagiegurari commented 2 weeks ago

@SamuelMarks good idea. would you like to PR it?