[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash completion and spaces



davidson wrote:
> > 
> > I actually looked with `hd` and expected to see 0x20 there, but
> > somehow see none of it:
> > 
> > $ echo $COMP_WORDBREAKS | hd
> > 00000000  22 27 40 3e 3c 3d 3b 7c  26 28 3a 0a              |"'@><=;|&(:.|
> > 0000000c
> 
> Above I count 12 characters piped from echo to hd. The final character
> is a newline added by echo, so that leaves 11 characters attributable
> to the content of COMP_WORDBREAKS.
> 
> But try this, below. It will tell you the length (in characters) of
> the content of COMP_WORDBREAKS.
> 
>  $ echo ${#COMP_WORDBREAKS}
>  14
> 
> So, when you do...
> 
>  $ echo $COMP_WORDBREAKS | hd
>  00000000  22 27 40 3e 3c 3d 3b 7c  26 28 3a 0a              |"'@><=;|&(:.|
>  0000000c
> 
> ...what accounts for the three missing characters (namely SPACE, TAB,
> and NEWLINE)?
> 
> TLDR: The shell's "word splitting" removes them, because you have not
> double-quoted the variable.

Oh, I see. Thanks.

-- 
Victor Sudakov VAS4-RIPE
http://vas.tomsk.ru/
2:5005/49@fidonet

Attachment: signature.asc
Description: PGP signature


Reply to: