Reputation: 25117
How could I escape the %
in this example?
func! my_func()
exec "!printf '=%.0s' {1..100}"
endfunc
Upvotes: 0
Views: 472
Reputation: 53644
Use shellescape
for any string that is a single argument (not a list of space-separated arguments) and may contains special characters (including space itself):
let suspicious_string='=%.0s'
exec "!printf ".shellescape(suspicious_string, 1)." {1..100}"
Upvotes: 3