duckscript icon indicating copy to clipboard operation
duckscript copied to clipboard

`printf` feature request

Open SamuelMarks opened this issue 1 year ago • 1 comments
trafficstars

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'

SamuelMarks avatar Aug 23 '24 03:08 SamuelMarks

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

sagiegurari avatar Aug 30 '24 11:08 sagiegurari