bun icon indicating copy to clipboard operation
bun copied to clipboard

$.escape should be renamed to $.raw

Open JLarky opened this issue 1 year ago • 2 comments

What is the problem this feature would solve?

$.escape does the opposite of what the name implies

What is the feature you are proposing to solve the problem?

Deprecate $.escape and add $.raw

What alternatives have you considered?

$.unescape? :-)

JLarky avatar Jan 21 '24 04:01 JLarky

fully agree this is confusing. i would expect escape to... well, escape the input.

trvswgnr avatar Jan 21 '24 04:01 trvswgnr

reasonable

Jarred-Sumner avatar Jan 21 '24 10:01 Jarred-Sumner

This is a mistake in the docs, $.escape actually does what is expected:

console.log($.escape('$(foo) `bar` "baz"'))
// Prints: \$(foo) \`bar\` \"baz\"

If you want to pass a string as raw input, use { raw: 'str' }:

await $`echo ${{ raw: '$(foo) `bar` "baz"' }}`

zackradisic avatar Feb 02 '24 21:02 zackradisic

Thanks for clarification, this makes much more sense :)

On Fri, Feb 2, 2024, 2:14 PM Zack Radisic @.***> wrote:

This is a mistake in the docs, $.escape actually does what is expected:

console.log($.escape('$(foo) bar "baz"'))// Prints: $(foo) `bar` "baz"

If you want to pass a string as raw input, use { raw: 'str' }:

await $echo ${{ raw: '$(foo) bar "baz"' }}

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/8318#issuecomment-1924705532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABW4QKXTYZE56YF4QBAZDYRVJK5AVCNFSM6AAAAABCDV4DOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRUG4YDKNJTGI . You are receiving this because you authored the thread.Message ID: @.***>

JLarky avatar Feb 06 '24 00:02 JLarky

let's fix the documentation of this. i was actually unaware of this too

paperclover avatar Feb 06 '24 00:02 paperclover

Fixed f77b217

zackradisic avatar Feb 09 '24 18:02 zackradisic