|
| From: | Eduardo A . Bustamante L贸pez |
| Subject: | Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted? |
| Date: | Tue, 24 Mar 2015 18:20:29 -0600 |
| User-agent: | Mutt/1.5.23 (2014-03-12) |
You have two options:
printf -v escaped_var %q "$var"
or
shquote() {
local q=\'
printf "'%s'" "${1//"$q"/$q\\$q$q}"
}
escaped_var=$(shquote "$var")
--
Eduardo Bustamante | https://dualbus.me/
| [Prev in Thread] | Current Thread | [Next in Thread] |