* [9fans] rc and whitespaces
@ 2014-11-26 13:02 Steve Simon
2014-11-26 13:24 ` Friedrich Psiorz
0 siblings, 1 reply; 3+ messages in thread
From: Steve Simon @ 2014-11-26 13:02 UTC (permalink / raw)
To: 9fans
rc using backquote to parse strings, e.g:
hugo% s=`{echo a b c}
hugo% echo $#s $s(1)
3 a
This is fine
hugo% s=`{echo 'a b' c}
hugo% echo $#s $s(1)
3 a
This is also fine, a b and c are just two fields when they
enter echo but they leave the appear to be 3 seperate words.
hugo% s=`{echo '''a b''' c}
hugo% echo $#s $s(1)
3 'a
This is disappointing, I was hoping that I would get
2 args and the first would be 'a b' (quotes here for
clarity, I was hoping there would be none in the assinged
variable $s
Is this what one would expect or is the text parsing
by `{ .. } different to rc's normal one - dare I say broken.
Is there a way round this?
Thanks,
-Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] rc and whitespaces
2014-11-26 13:02 [9fans] rc and whitespaces Steve Simon
@ 2014-11-26 13:24 ` Friedrich Psiorz
2014-11-26 13:33 ` erik quanstrom
0 siblings, 1 reply; 3+ messages in thread
From: Friedrich Psiorz @ 2014-11-26 13:24 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
That behaviour is what I would expect. rc splits text in `{} according
to $ifs, which is usually space, tab, and newline. It doesn't treat any
characters special, including quotes.
Am 26.11.2014 um 14:02 schrieb Steve Simon:
> rc using backquote to parse strings, e.g:
>
> hugo% s=`{echo a b c}
> hugo% echo $#s $s(1)
> 3 a
> This is fine
>
> hugo% s=`{echo 'a b' c}
> hugo% echo $#s $s(1)
> 3 a
> This is also fine, a b and c are just two fields when they
> enter echo but they leave the appear to be 3 seperate words.
>
> hugo% s=`{echo '''a b''' c}
> hugo% echo $#s $s(1)
> 3 'a
> This is disappointing, I was hoping that I would get
> 2 args and the first would be 'a b' (quotes here for
> clarity, I was hoping there would be none in the assinged
> variable $s
>
> Is this what one would expect or is the text parsing
> by `{ .. } different to rc's normal one - dare I say broken.
>
> Is there a way round this?
>
> Thanks,
>
> -Steve
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] rc and whitespaces
2014-11-26 13:24 ` Friedrich Psiorz
@ 2014-11-26 13:33 ` erik quanstrom
0 siblings, 0 replies; 3+ messages in thread
From: erik quanstrom @ 2014-11-26 13:33 UTC (permalink / raw)
To: 9fans
> This is also fine, a b and c are just two fields when they
> enter echo but they leave the appear to be 3 seperate words.
>
> hugo% s=`{echo '''a b''' c}
> hugo% echo $#s $s(1)
> 3 'a
> This is disappointing, I was hoping that I would get
> 2 args and the first would be 'a b' (quotes here for
> clarity, I was hoping there would be none in the assinged
> variable $s
>
> Is this what one would expect or is the text parsing
> by `{ .. } different to rc's normal one - dare I say broken.
f.psiorz@gmx.de is correct. expected behavior. you could wrap
tokenize in a little program outputting a token per line and then do
ifs=$nl s=`{echo $list | tokenize}
9atom's rc has additional syntax that prevents ifs from being
global shared state (and the source of many script interation bugs)
s=`$nl {echo $list | tokenize}
- erik
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-26 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 13:02 [9fans] rc and whitespaces Steve Simon
2014-11-26 13:24 ` Friedrich Psiorz
2014-11-26 13:33 ` erik quanstrom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).