9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rc: null list in concatenation
@ 2014-11-25  4:24 trebol
  2014-11-25  6:08 ` arisawa
  0 siblings, 1 reply; 9+ messages in thread
From: trebol @ 2014-11-25  4:24 UTC (permalink / raw)
  To: 9fans

Hello everyone.

I'm curious about the behavior of rc concatenating null strings (brakes
execution on error...).  It's a feature, rationally thought-out, or a bug?

If anyone can tell me the story behind, I'll be grateful.

trebol.

P.D.
Sorry for previous mail without subject.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
  2014-11-25  4:24 [9fans] rc: null list in concatenation trebol
@ 2014-11-25  6:08 ` arisawa
  2014-11-25  6:56   ` trebol
  0 siblings, 1 reply; 9+ messages in thread
From: arisawa @ 2014-11-25  6:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: 9fans

example is required.

> 2014/11/25 13:24、trebol@india.com のメール:
> 
> Hello everyone.
> 
> I'm curious about the behavior of rc concatenating null strings (brakes
> execution on error...).  It's a feature, rationally thought-out, or a bug?
> 
> If anyone can tell me the story behind, I'll be grateful.
> 
> trebol.
> 
> P.D.
> Sorry for previous mail without subject.
> 
> 




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
  2014-11-25  6:08 ` arisawa
@ 2014-11-25  6:56   ` trebol
  2014-11-25  8:30     ` arisawa
  0 siblings, 1 reply; 9+ messages in thread
From: trebol @ 2014-11-25  6:56 UTC (permalink / raw)
  To: 9fans

a = `{ls file}^test; echo 'this part is not executed if file doesn''t exist'


> example is required.
> 
>> 2014/11/25 13:24、trebol@india.com のメール:
>> 
>> Hello everyone.
>> 
>> I'm curious about the behavior of rc concatenating null strings (brakes
>> execution on error...).  It's a feature, rationally thought-out, or a bug?
>> 
>> If anyone can tell me the story behind, I'll be grateful.
>> 
>> trebol.
>> 
>> P.D.
>> Sorry for previous mail without subject.
>> 
>> 




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
  2014-11-25  6:56   ` trebol
@ 2014-11-25  8:30     ` arisawa
  2014-11-25 10:00       ` Charles Forsyth
  0 siblings, 1 reply; 9+ messages in thread
From: arisawa @ 2014-11-25  8:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs


> 2014/11/25 15:56、trebol@india.com のメール:
> 
> a = `{ls file}^test; echo 'this part is not executed if file doesn''t exist'

probably your question is as follows:

maia% a = `{ls file}^test; echo 'this part is not executed if file doesn''t exist'
ls: file: 'file' directory entry not found
rc: null list in concatenation
maia% 

on the other hand,

maia% ls file;  echo 'this part is not executed if file doesn''t exist'
ls: file: 'file' directory entry not found
this part is not executed if file doesn't exist
maia% 

a similar  thing is:
maia% (aa bb)=aaaa; echo bbbb
rc: variable name not singleton!
maia% 

perhaps this is a feature.
rc stops execution if there is an error in grammar.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
  2014-11-25  8:30     ` arisawa
@ 2014-11-25 10:00       ` Charles Forsyth
  2014-11-25 19:37         ` trebol
  0 siblings, 1 reply; 9+ messages in thread
From: Charles Forsyth @ 2014-11-25 10:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

It's a "null list" not a "null string". You can use a null string:

% s=''
% ls $s^/x

but not a null list (like using null in many lisp list operations, or the
difference between strcat of nil and strcat of ""):

% s=()
% ls $s^/x
rc (-/bin/rc): null list in concatenation

A completely unset variable is a null list. Also, `{...} returns  a list
(of words) not a string,
hence the diagnostic in that case.

[-- Attachment #2: Type: text/html, Size: 857 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
  2014-11-25 10:00       ` Charles Forsyth
@ 2014-11-25 19:37         ` trebol
  0 siblings, 0 replies; 9+ messages in thread
From: trebol @ 2014-11-25 19:37 UTC (permalink / raw)
  To: 9fans

> maia% (aa bb)=aaaa; echo bbbb
> rc: variable name not singleton!

Interesting, I could expect something like
'(aa bb) = aaaa --> aa=aaaa bb=aaaa'
but of course there is not a concatenation, but an assigment.

> It's a "null list" not a "null string". You can use a null string:
>
> % s=''
> % ls $s^/x
>
> but not a null list (like using null in many lisp list operations, or the
> difference between strcat of nil and strcat of ""):
>
> % s=()
> % ls $s^/x
> rc (-/bin/rc): null list in concatenation
>
> A completely unset variable is a null list. Also, `{...} returns  a list
> (of words) not a string,
> hence the diagnostic in that case.

Yeah... thanks a lot!
So the correct way must bem something like:

a = ('' `{ls file})^test; echo 'this part _is_ executed if file doesn''t exist'

I feel ashamed... The man page is beautifully written, except may be the
'\t\n' notation. Now this is not confusing for me because I've in mind that
Plan9 ignore those escape sequence, but at first with my unix reflexes
that was a problem, and I think it's important to remember those first
steps to improve documentation.

I remember the first time I type.
$ man bash

I had to power off the computer and go to the beach.

trebol.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
@ 2014-11-26  6:34 trebol
  0 siblings, 0 replies; 9+ messages in thread
From: trebol @ 2014-11-26  6:34 UTC (permalink / raw)
  To: 9fans

Sorry for all that noise.  The problem was simply confusion about strings,
list of strings, list of strings and|or other list of strings... and
too much coffee.

What I needed was simply the use of $" to work around possible empty
lists in concatenations (and of course read the man page carefully
again and again), my fault, sorry again.

trebol.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
       [not found] <fef8ab0af3b38f58c82f797482943532@india.com>
  2014-11-25 20:44 ` trebol
@ 2014-11-25 20:47 ` trebol
  1 sibling, 0 replies; 9+ messages in thread
From: trebol @ 2014-11-25 20:47 UTC (permalink / raw)
  To: 9fans

> My be my poor English

It's the proof itself!




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] rc: null list in concatenation
       [not found] <fef8ab0af3b38f58c82f797482943532@india.com>
@ 2014-11-25 20:44 ` trebol
  2014-11-25 20:47 ` trebol
  1 sibling, 0 replies; 9+ messages in thread
From: trebol @ 2014-11-25 20:44 UTC (permalink / raw)
  To: 9fans

> Also, when the '^' is omitted, like in
>
> 	$dir(1)^$dir(2)

 Also, when the '^' is omitted, like in

 	$dir(1)$dir(2)

Sorry for the mess...




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-26  6:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25  4:24 [9fans] rc: null list in concatenation trebol
2014-11-25  6:08 ` arisawa
2014-11-25  6:56   ` trebol
2014-11-25  8:30     ` arisawa
2014-11-25 10:00       ` Charles Forsyth
2014-11-25 19:37         ` trebol
     [not found] <fef8ab0af3b38f58c82f797482943532@india.com>
2014-11-25 20:44 ` trebol
2014-11-25 20:47 ` trebol
2014-11-26  6:34 trebol

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).