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

Re: PATCH: expanding parameters like echo/print builtins



On 11 May 2011 19:07, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Wed, 11 May 2011 18:38:46 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> The c and e flags will have tendencies to output unprintable
>> characters, can I write them in the expected test output somehow?
>
> The way to do this is to capture the output via a pipe or $(...) or
> whatever and then make that output readable by using ${(q)...} or
> something such.  There will be examples somewhere.  This does rely on
> the shell getting the reverse conversion right, but we test the features
> its relying on elsewhere so in theory we shouldn't get errors cancelling
> each other out.  (I'm loath to rely on od, and certainly xxd isn't
> standard enough.)

Hm, or could I use ${(V)${(g:c:):-'^X'}}? (actually putting V in the
same parens work, but the order isn't documented). (Should the order
parameter expansion flags are applied in be documented somewhere?)

  foo='\u65\123'
  print -r ${(g:o:)foo}
  foo='\u65\0123'
  print -r ${(g::)foo}
  foo='\u65^X'
  print -r ${(V)${(g:c:)foo}}
  foo='\u65\C-x\M-a'
  print -r ${(V)${(g:e:)foo}}
  foo='\u65\123\C-x'
  print -r ${(V)${(g:eo:)foo}}
0:${(g)...}
>eS
>eS
>e^X
>e^X\M-a
>eS^X

-- 
Mikael Magnusson



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