Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vared/zle silently discards non-utf8 bytes



Peter Stephenson wrote:
> varedquote() {
>   # ignoring vared options for now....
>   local var=${argv[-1]}
>   local val=${(q)${(P)var}}
>   # hmmm... if the user stripped some quoting the following is
>   # a bit fraught...
>   vared val && eval ${var}=${val}
> }
> 
> should work because the (q) flag is already smart about unprintable
> characters (except it does rely on the user not removing backslashes in the
> variable).

Much better:

varedquote() {
  # ignoring vared options for now....
  local var=${argv[-1]}
  local val=${(q)${(P)var}}
  vared val && eval ${var}="\${(Q)val}"
}

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



Messages sorted by: Reverse Date, Date, Thread, Author