9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] simple question: multiple rename
@ 2009-06-05 19:58 Rudolf Sykora
  2009-06-05 20:04 ` Martin Harriss
  2009-06-08  7:50 ` Rudolf Sykora
  0 siblings, 2 replies; 25+ messages in thread
From: Rudolf Sykora @ 2009-06-05 19:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

I realized I cannot come up with a simple solution for the following.
I want to rename all the files whose names end with _g_b to just _g,
e.g. hello_g_b should be renamed to hello_g.
I simply don't know an easy way.
[the opposite way is simple: for(i in *_g) mv $i $i^_b ]
I only think about so complicated ways like

for(i in *_g_b) {
    s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
        1s/(.+)_g/\1
        p
        EOF
        }
    mv $i $s
}

which describes my idea, but doesn't work, actually. (btw. how can one
correct it?)

Thanks
Ruda



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

* Re: [9fans] simple question: multiple rename
  2009-06-05 19:58 [9fans] simple question: multiple rename Rudolf Sykora
@ 2009-06-05 20:04 ` Martin Harriss
  2009-06-05 20:07   ` Rudolf Sykora
  2009-06-08  7:50 ` Rudolf Sykora
  1 sibling, 1 reply; 25+ messages in thread
From: Martin Harriss @ 2009-06-05 20:04 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Rudolf Sykora wrote:
> Hello,
>
> I realized I cannot come up with a simple solution for the following.
> I want to rename all the files whose names end with _g_b to just _g,
> e.g. hello_g_b should be renamed to hello_g.
> I simply don't know an easy way.
> [the opposite way is simple: for(i in *_g) mv $i $i^_b ]
> I only think about so complicated ways like
>
> for(i in *_g_b) {
>     s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
>         1s/(.+)_g/\1
>         p
>         EOF
>         }
>     mv $i $s
> }
>
> which describes my idea, but doesn't work, actually. (btw. how can one
> correct it?)
>
> Thanks
> Ruda
>

sed is your friend:

s=`{ echo $i | sed -e 's/_g_b/_g/' }


Martin




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

* Re: [9fans] simple question: multiple rename
  2009-06-05 20:04 ` Martin Harriss
@ 2009-06-05 20:07   ` Rudolf Sykora
  0 siblings, 0 replies; 25+ messages in thread
From: Rudolf Sykora @ 2009-06-05 20:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> sed is your friend:
>
> s=`{ echo $i | sed -e 's/_g_b/_g/' }
>
>
> Martin

Oh yes, that's it.
Thanks
Ruda



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

* Re: [9fans] simple question: multiple rename
  2009-06-05 19:58 [9fans] simple question: multiple rename Rudolf Sykora
  2009-06-05 20:04 ` Martin Harriss
@ 2009-06-08  7:50 ` Rudolf Sykora
  2009-06-08  9:35   ` Russ Cox
  2009-06-08  9:45   ` Martin Neubauer
  1 sibling, 2 replies; 25+ messages in thread
From: Rudolf Sykora @ 2009-06-08  7:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,
Still wonder, what's the right way to make the following work:

This is ok:

sam -d <<EOF <{echo $i} >[2] /dev/null
        1s/(.+)_g/\1
        p
        EOF

but now I want it all be inside `{}, like

s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
        1s/(.+)_g/\1
        p
        EOF
       }

which doesn't work. I tried several ways, but unsuccessfully. Anyway,
I guess it should be easy...

Thanks
Ruda



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

* Re: [9fans] simple question: multiple rename
  2009-06-08  7:50 ` Rudolf Sykora
@ 2009-06-08  9:35   ` Russ Cox
  2009-06-16 11:51     ` roger peppe
  2009-06-08  9:45   ` Martin Neubauer
  1 sibling, 1 reply; 25+ messages in thread
From: Russ Cox @ 2009-06-08  9:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Mon, Jun 8, 2009 at 12:50 AM, Rudolf Sykora<rudolf.sykora@gmail.com> wrote:
> Hello,
> Still wonder, what's the right way to make the following work:

The right way is

s=`{echo $i | sed 's/(.+)_g/\1/'}.

> s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
>        1s/(.+)_g/\1
>        p
>        EOF
>       }

If you must use sam, the right way is

s=`{echo '1s/(.+)_g/
p' | sam -d <{echo $i} >[2]/dev/null }

If you must use here docs, the way that works is

s=`{sam -d <<EOF <{echo $i} >[2]/dev/null}
1s/(.+)_g/\1
p
EOF

Russ


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

* Re: [9fans] simple question: multiple rename
  2009-06-08  7:50 ` Rudolf Sykora
  2009-06-08  9:35   ` Russ Cox
@ 2009-06-08  9:45   ` Martin Neubauer
  2009-06-08 10:40     ` Rudolf Sykora
  1 sibling, 1 reply; 25+ messages in thread
From: Martin Neubauer @ 2009-06-08  9:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello Ruda,

Due to the peculiarities of here documents in rc the following:
> s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
>         1s/(.+)_g/\1
>         p
>         EOF
>        }
should be written as:
s = `{sam -d <<EOF <{echo $i} >[2] /dev/null}
	...
	EOF

Hope that helps,
	Martin



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

* Re: [9fans] simple question: multiple rename
  2009-06-08  9:45   ` Martin Neubauer
@ 2009-06-08 10:40     ` Rudolf Sykora
  0 siblings, 0 replies; 25+ messages in thread
From: Rudolf Sykora @ 2009-06-08 10:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> should be written as:
> s = `{sam -d <<EOF <{echo $i} >[2] /dev/null}
>        ...
>        EOF
>
> Hope that helps,
>        Martin

OK, now I see. The } was at the wrong place...
Thanks Martin
thanks Russ, too.

Ruda



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

* Re: [9fans] simple question: multiple rename
  2009-06-08  9:35   ` Russ Cox
@ 2009-06-16 11:51     ` roger peppe
  2009-06-16 12:00       ` erik quanstrom
  0 siblings, 1 reply; 25+ messages in thread
From: roger peppe @ 2009-06-16 11:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/6/8 Russ Cox <rsc@swtch.com>
> On Mon, Jun 8, 2009 at 12:50 AM, Rudolf Sykora<rudolf.sykora@gmail.com> wrote:
> > Hello,
> > Still wonder, what's the right way to make the following work:
>
> The right way is
>
> s=`{echo $i | sed 's/(.+)_g/\1/'}.

note that this won't work if the filenames contain white space.

(i still regret the fact that white space became allowable in file names)



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 11:51     ` roger peppe
@ 2009-06-16 12:00       ` erik quanstrom
  2009-06-16 12:43         ` Ethan Grammatikidis
  0 siblings, 1 reply; 25+ messages in thread
From: erik quanstrom @ 2009-06-16 12:00 UTC (permalink / raw)
  To: 9fans

> note that this won't work if the filenames contain white space.
>
> (i still regret the fact that white space became allowable in file names)

using ws in filenames is a fossil-only problem;
kfs, cwfs and ken's fs won't allow it.

fortunately, fossil is easy to fix

/n/dump/2009/0616/sys/src/cmd/fossil/9p.c:102,108 - 9p.c:102,108
  	}

  	for(p = name; *p != '\0'; p++){
- 		if((*p & 0xFF) < 040){
+ 		if((*p & 0xFF) <= 040){
  			vtSetError("bad character in file name");
  			return 0;
  		}

- erik



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:00       ` erik quanstrom
@ 2009-06-16 12:43         ` Ethan Grammatikidis
  2009-06-16 12:52           ` erik quanstrom
                             ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Ethan Grammatikidis @ 2009-06-16 12:43 UTC (permalink / raw)
  To: 9fans

On Tue, 16 Jun 2009 08:00:44 -0400
erik quanstrom <quanstro@quanstro.net> wrote:

> > note that this won't work if the filenames contain white space.
> >
> > (i still regret the fact that white space became allowable in file names)
>
> using ws in filenames is a fossil-only problem;
> kfs, cwfs and ken's fs won't allow it.
>
> fortunately, fossil is easy to fix
>
> /n/dump/2009/0616/sys/src/cmd/fossil/9p.c:102,108 - 9p.c:102,108
>   	}
>
>   	for(p = name; *p != '\0'; p++){
> - 		if((*p & 0xFF) < 040){
> + 		if((*p & 0xFF) <= 040){
>   			vtSetError("bad character in file name");
>   			return 0;
>   		}
>
> - erik
>

So what happens when you drawterm from a un*x box or access a VFAT partition? Perhaps 9fat could dynamically translate spaces in filenames to some character illegal in Windows file names and not special to rc, if there is such a character. I don't recall what characters are illegal in Windows filenames but for the purposes of example assume ~ is illegal:

On-disk filename:
	Program Files
9fat represents this to plan 9 processes as:
	Program~Files

To pick an extreme (and fictional) example:
on-disk:
The Evolution of Conciousness in the Breakdown of the Bicameral Mind.doc
translated:
The~Evolution~of~Conciousness~in~the~Breakdown~of~the~Bicameral~Mind.doc
or
The]Evolution]of]Conciousness]in]the]Breakdown]of]the]Bicameral]Mind.doc
etc.

It would be great if the substitute character could be one not special to regexps.


Un*x seems a harder issue since no character is actually illegal, but I notice many ASCII control characters are not at all special to plan 9 or drawterm and are extremely unlikely to be present in a un*x filename. Vertical tab, perhaps; control-K. For that matter this trick could be used for Windows filesystems too, I'm quite sure control-chars are unacceptable there.


--
Ethan Grammatikidis
The lyf so short, the craft so long to lerne. -- Chaucer



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:43         ` Ethan Grammatikidis
@ 2009-06-16 12:52           ` erik quanstrom
  2009-06-16 14:07             ` Russ Cox
  2009-06-16 23:00             ` Ethan Grammatikidis
  2009-06-16 15:48           ` Charles Forsyth
  2009-06-16 15:55           ` john
  2 siblings, 2 replies; 25+ messages in thread
From: erik quanstrom @ 2009-06-16 12:52 UTC (permalink / raw)
  To: 9fans

> So what happens when you drawterm from a un*x box or access a VFAT partition?

nothing.  i'm running ken's fs, so from drawterm i have

	; echo > 'silly file'
	; lc silly*
	'silly file'
	; cd /tmp
	; echo > 'silly file'
	silly file: rc: can't open: 'silly file' create/wstat -- bad character in file name

> Un*x seems a harder issue since no character is actually illegal,

\0 is illegal.  well, not so much illegal as impossible to specify.
(wide characters notwithstanding.)

- erik



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:52           ` erik quanstrom
@ 2009-06-16 14:07             ` Russ Cox
  2009-06-16 14:40               ` erik quanstrom
  2009-06-16 23:00             ` Ethan Grammatikidis
  1 sibling, 1 reply; 25+ messages in thread
From: Russ Cox @ 2009-06-16 14:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

the easiest thing to do is not use spaces in
your file names, even if others do in theirs.
most people take that approach, even on unix,
and it works fine.

if you are worried about names with spaces
and want to make a script more robust, then
the simplest option is to set ifs='
'
while you are manipulating the file names
with `{} commands.  spaces may be allowed
but newlines most certainly are not.  i keep
nl='
'
in my profile specifically so i can say ifs=$nl.

> using ws in filenames is a fossil-only problem;
> kfs, cwfs and ken's fs won't allow it.

gee, i'm pretty sure i read somewhere that
plan 9 lets any program be a file server ...

>> So what happens when you drawterm from a un*x box or access a VFAT partition?
>
> nothing.  i'm running ken's fs, so from drawterm ...

the question (quoted) was about talking to non-plan 9
file systems, i.e. a linux or windows /mnt/term or
a dossrv disk.

if you are trying to disallow space you'd have
to fiddle with every file server you could possibly
talk to, or you'd have to edit the kernel.
the barn door has been open for a decade.
it's very late to be talking about closing it.
http://swtch.com/cgi-bin/plan9history.cgi?f=1999/0323/port/chan.c;v=diff;e=1

russ


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

* Re: [9fans] simple question: multiple rename
  2009-06-16 14:07             ` Russ Cox
@ 2009-06-16 14:40               ` erik quanstrom
  0 siblings, 0 replies; 25+ messages in thread
From: erik quanstrom @ 2009-06-16 14:40 UTC (permalink / raw)
  To: 9fans

> if you are trying to disallow space you'd have
> to fiddle with every file server you could possibly
> talk to, or you'd have to edit the kernel.
> the barn door has been open for a decade.

my point was only that i agree with roger; spaces in
filenames are a pain and it would be best not
to let them on the fileserver.  (we're allowed to
talk about "the fileserver", aren't we?  even if
there are technically many of them?)

> it's very late to be talking about closing it.
> http://swtch.com/cgi-bin/plan9history.cgi?f=1999/0323/port/chan.c;v=diff;e=1

is your point that old mistakes should never
be fixed?

- erik



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 15:48           ` Charles Forsyth
@ 2009-06-16 15:31             ` erik quanstrom
  2009-06-16 22:57               ` Ethan Grammatikidis
  0 siblings, 1 reply; 25+ messages in thread
From: erik quanstrom @ 2009-06-16 15:31 UTC (permalink / raw)
  To: 9fans

> >The Evolution of Conciousness in the Breakdown of the Bicameral Mind.doc
>
> it's not worth worrying about for that book (i think it's `Origin' not `Evolution')
> i am astounded it keeps resurfacing.

those crazy nebraskans.

- erik



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:43         ` Ethan Grammatikidis
  2009-06-16 12:52           ` erik quanstrom
@ 2009-06-16 15:48           ` Charles Forsyth
  2009-06-16 15:31             ` erik quanstrom
  2009-06-16 15:55           ` john
  2 siblings, 1 reply; 25+ messages in thread
From: Charles Forsyth @ 2009-06-16 15:48 UTC (permalink / raw)
  To: 9fans

>The Evolution of Conciousness in the Breakdown of the Bicameral Mind.doc

it's not worth worrying about for that book (i think it's `Origin' not `Evolution')
i am astounded it keeps resurfacing.



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:43         ` Ethan Grammatikidis
  2009-06-16 12:52           ` erik quanstrom
  2009-06-16 15:48           ` Charles Forsyth
@ 2009-06-16 15:55           ` john
  2009-06-16 17:19             ` Tim Newsham
  2009-06-16 23:05             ` Ethan Grammatikidis
  2 siblings, 2 replies; 25+ messages in thread
From: john @ 2009-06-16 15:55 UTC (permalink / raw)
  To: 9fans

> On Tue, 16 Jun 2009 08:00:44 -0400
> erik quanstrom <quanstro@quanstro.net> wrote:
>
>> > note that this won't work if the filenames contain white space.
>> >
>> > (i still regret the fact that white space became allowable in file names)
>>
>> using ws in filenames is a fossil-only problem;
>> kfs, cwfs and ken's fs won't allow it.
>>
>> fortunately, fossil is easy to fix
>>
>> /n/dump/2009/0616/sys/src/cmd/fossil/9p.c:102,108 - 9p.c:102,108
>>   	}
>>
>>   	for(p = name; *p != '\0'; p++){
>> - 		if((*p & 0xFF) < 040){
>> + 		if((*p & 0xFF) <= 040){
>>   			vtSetError("bad character in file name");
>>   			return 0;
>>   		}
>>
>> - erik
>>
>
> So what happens when you drawterm from a un*x box or access a VFAT partition? Perhaps 9fat could dynamically translate spaces in filenames to some character illegal in Windows file names and not special to rc, if there is such a character. I don't recall what characters are illegal in Windows filenames but for the purposes of example assume ~ is illegal:

I believe it was Nemo et al.  who wrote trfs, which does essentially
what you want--it stands between you and your badly-named files,
presenting spaces as underscores or something to that effect.

John




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

* Re: [9fans] simple question: multiple rename
  2009-06-16 15:55           ` john
@ 2009-06-16 17:19             ` Tim Newsham
  2009-06-16 23:05             ` Ethan Grammatikidis
  1 sibling, 0 replies; 25+ messages in thread
From: Tim Newsham @ 2009-06-16 17:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I believe it was Nemo et al.  who wrote trfs, which does essentially
> what you want--it stands between you and your badly-named files,
> presenting spaces as underscores or something to that effect.

In inferno (at least in acme-sac) the spaces coming from
my native (windows) filesystem are translated into some unicode
underscore type character.  Definitely makes for easier plumbing.
   http://www.thenewsh.com/~newsham/x/machine/inferno-acme-space.jpg

> John

Tim Newsham
http://www.thenewsh.com/~newsham/



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 15:31             ` erik quanstrom
@ 2009-06-16 22:57               ` Ethan Grammatikidis
  0 siblings, 0 replies; 25+ messages in thread
From: Ethan Grammatikidis @ 2009-06-16 22:57 UTC (permalink / raw)
  To: 9fans

> > >The Evolution of Conciousness in the Breakdown of the Bicameral Mind.doc
> >
> > it's not worth worrying about for that book (i think it's `Origin' not `Evolution')
> > i am astounded it keeps resurfacing.
>
> those crazy nebraskans.

Don't mind me I'm just quoting Hitchhiker's Guide to the Galaxy. ^.^; I think you're right, it's Origin not Evolution.

--
Ethan Grammatikidis
The lyf so short, the craft so long to lerne. -- Chaucer



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 12:52           ` erik quanstrom
  2009-06-16 14:07             ` Russ Cox
@ 2009-06-16 23:00             ` Ethan Grammatikidis
  2009-06-16 23:01               ` erik quanstrom
  1 sibling, 1 reply; 25+ messages in thread
From: Ethan Grammatikidis @ 2009-06-16 23:00 UTC (permalink / raw)
  To: 9fans

On Tue, 16 Jun 2009 08:52:43 -0400
erik quanstrom <quanstro@quanstro.net> wrote:

> > So what happens when you drawterm from a un*x box or access a VFAT partition?
>
> nothing.  i'm running ken's fs, so from drawterm i have
>
> 	; echo > 'silly file'
> 	; lc silly*
> 	'silly file'
> 	; cd /tmp
> 	; echo > 'silly file'
> 	silly file: rc: can't open: 'silly file' create/wstat -- bad character in file name
>
> > Un*x seems a harder issue since no character is actually illegal,
>
> \0 is illegal.  well, not so much illegal as impossible to specify.
> (wide characters notwithstanding.)

I forgot, / is actually illegal. I'm almost (but not quite) certain that \0 is legal, and if I understand my emacs correctly you may be able to type it as ctrl-space. It displays as ^@ in emacs.


--
Ethan Grammatikidis
The lyf so short, the craft so long to lerne. -- Chaucer



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 23:00             ` Ethan Grammatikidis
@ 2009-06-16 23:01               ` erik quanstrom
  2009-06-17 14:34                 ` Ethan Grammatikidis
  2009-06-18 22:54                 ` John Floren
  0 siblings, 2 replies; 25+ messages in thread
From: erik quanstrom @ 2009-06-16 23:01 UTC (permalink / raw)
  To: 9fans

> I forgot, / is actually illegal. I'm almost (but not quite) certain that \0 is legal, and if I understand my emacs correctly you may be able to type it as ctrl-space. It displays as ^@ in emacs.
>

what system call do you use to create a file with \0 in the name?
i'm not really keeping up, but last i checked creat doesn't take
a filename length, and therefore the null will terminate the string.

- erik



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 15:55           ` john
  2009-06-16 17:19             ` Tim Newsham
@ 2009-06-16 23:05             ` Ethan Grammatikidis
  1 sibling, 0 replies; 25+ messages in thread
From: Ethan Grammatikidis @ 2009-06-16 23:05 UTC (permalink / raw)
  To: 9fans

On Tue, 16 Jun 2009 11:55:42 -0400
john@csplan9.rit.edu wrote:

> > On Tue, 16 Jun 2009 08:00:44 -0400
> > erik quanstrom <quanstro@quanstro.net> wrote:
> >
> >> > note that this won't work if the filenames contain white space.
> >> >
> >> > (i still regret the fact that white space became allowable in file names)
> >>
> >> using ws in filenames is a fossil-only problem;
> >> kfs, cwfs and ken's fs won't allow it.
> >>
> >> fortunately, fossil is easy to fix
> >>
> >> /n/dump/2009/0616/sys/src/cmd/fossil/9p.c:102,108 - 9p.c:102,108
> >>   	}
> >>
> >>   	for(p = name; *p != '\0'; p++){
> >> - 		if((*p & 0xFF) < 040){
> >> + 		if((*p & 0xFF) <= 040){
> >>   			vtSetError("bad character in file name");
> >>   			return 0;
> >>   		}
> >>
> >> - erik
> >>
> >
> > So what happens when you drawterm from a un*x box or access a VFAT partition? Perhaps 9fat could dynamically translate spaces in filenames to some character illegal in Windows file names and not special to rc, if there is such a character. I don't recall what characters are illegal in Windows filenames but for the purposes of example assume ~ is illegal:
>
> I believe it was Nemo et al.  who wrote trfs, which does essentially
> what you want--it stands between you and your badly-named files,
> presenting spaces as underscores or something to that effect.

trfs sounds like the tool for the job alright. Will get it as soon as I can.

--
Ethan Grammatikidis
The lyf so short, the craft so long to lerne. -- Chaucer



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 23:01               ` erik quanstrom
@ 2009-06-17 14:34                 ` Ethan Grammatikidis
  2009-06-18 22:54                 ` John Floren
  1 sibling, 0 replies; 25+ messages in thread
From: Ethan Grammatikidis @ 2009-06-17 14:34 UTC (permalink / raw)
  To: 9fans

On Tue, 16 Jun 2009 19:01:43 -0400
erik quanstrom <quanstro@coraid.com> wrote:

> > I forgot, / is actually illegal. I'm almost (but not quite) certain that \0 is legal, and if I understand my emacs correctly you may be able to type it as ctrl-space. It displays as ^@ in emacs.
> >
>
> what system call do you use to create a file with \0 in the name?
> i'm not really keeping up, but last i checked creat doesn't take
> a filename length, and therefore the null will terminate the string.
>
> - erik
>

Ah you're right there.


--
Ethan Grammatikidis
The lyf so short, the craft so long to lerne. -- Chaucer



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

* Re: [9fans] simple question: multiple rename
  2009-06-16 23:01               ` erik quanstrom
  2009-06-17 14:34                 ` Ethan Grammatikidis
@ 2009-06-18 22:54                 ` John Floren
  2009-06-18 22:59                   ` erik quanstrom
  1 sibling, 1 reply; 25+ messages in thread
From: John Floren @ 2009-06-18 22:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Jun 16, 2009 at 4:01 PM, erik quanstrom <quanstro@coraid.com> wrote:
>
> > I forgot, / is actually illegal. I'm almost (but not quite) certain that \0 is legal, and if I understand my emacs correctly you may be able to type it as ctrl-space. It displays as ^@ in emacs.
> >
>
> what system call do you use to create a file with \0 in the name?
> i'm not really keeping up, but last i checked creat doesn't take
> a filename length, and therefore the null will terminate the string.
>
> - erik
>

According to intro(5), \0 is illegal in a 9P text string. "The NUL
character is illegal in all text strings in 9P, and is therefore
excluded from file names, user names, and so on." I'm assuming from
this that Thou Shall Not Use NUL In Filenames.


John
--
"I've tried programming Ruby on Rails, following TechCrunch in my RSS
reader, and drinking absinthe. It doesn't work. I'm going back to C,
Hunter S. Thompson, and cheap whiskey." -- Ted Dziuba



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

* Re: [9fans] simple question: multiple rename
  2009-06-18 22:54                 ` John Floren
@ 2009-06-18 22:59                   ` erik quanstrom
  0 siblings, 0 replies; 25+ messages in thread
From: erik quanstrom @ 2009-06-18 22:59 UTC (permalink / raw)
  To: 9fans

On Thu Jun 18 18:55:30 EDT 2009, slawmaster@gmail.com wrote:
> On Tue, Jun 16, 2009 at 4:01 PM, erik quanstrom <quanstro@coraid.com> wrote:
> >
> > > I forgot, / is actually illegal. I'm almost (but not quite) certain that \0 is legal, and if I understand my emacs correctly you may be able to type it as ctrl-space. It displays as ^@ in emacs.
> > >
> >
> > what system call do you use to create a file with \0 in the name?
> > i'm not really keeping up, but last i checked creat doesn't take
> > a filename length, and therefore the null will terminate the string.
> >
> > - erik
> >
>
> According to intro(5), \0 is illegal in a 9P text string. "The NUL
> character is illegal in all text strings in 9P, and is therefore
> excluded from file names, user names, and so on." I'm assuming from
> this that Thou Shall Not Use NUL In Filenames.

note the spelling of creat.  intro(5) does not apply to unix.

- erik



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

* Re: [9fans] simple question: multiple rename
@ 2009-06-16 18:34 Francisco J Ballesteros
  0 siblings, 0 replies; 25+ messages in thread
From: Francisco J Ballesteros @ 2009-06-16 18:34 UTC (permalink / raw)
  To: 9fans

We always use trfs in the 9fs script.
It's so convenient that we forgot it's there.

I think it's in contrib. Otherwise let me know.

El 16/06/2009, a las 17:58, john@csplan9.rit.edu escribió:

>> On Tue, 16 Jun 2009 08:00:44 -0400
>> erik quanstrom <quanstro@quanstro.net> wrote:
>>
>>>> note that this won't work if the filenames contain white space.
>>>>
>>>> (i still regret the fact that white space became allowable in  
>>>> file names)
>>>
>>> using ws in filenames is a fossil-only problem;
>>> kfs, cwfs and ken's fs won't allow it.
>>>
>>> fortunately, fossil is easy to fix
>>>
>>> /n/dump/2009/0616/sys/src/cmd/fossil/9p.c:102,108 - 9p.c:102,108
>>>    }
>>>
>>>    for(p = name; *p != '\0'; p++){
>>> -        if((*p & 0xFF) < 040){
>>> +        if((*p & 0xFF) <= 040){
>>>            vtSetError("bad character in file name");
>>>            return 0;
>>>        }
>>>
>>> - erik
>>>
>>
>> So what happens when you drawterm from a un*x box or access a VFAT  
>> partition? Perhaps 9fat could dynamically translate spaces in  
>> filenames to some character illegal in Windows file names and not  
>> special to rc, if there is such a character. I don't recall what  
>> characters are illegal in Windows filenames but for the purposes of  
>> example assume ~ is illegal:
>
> I believe it was Nemo et al. who wrote trfs, which does essentially
> what you want--it stands between you and your badly-named files,
> presenting spaces as underscores or something to that effect.
>
> John
>
>
> [/mail/box/nemo/msgs/200906/42195]



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

end of thread, other threads:[~2009-06-18 22:59 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 19:58 [9fans] simple question: multiple rename Rudolf Sykora
2009-06-05 20:04 ` Martin Harriss
2009-06-05 20:07   ` Rudolf Sykora
2009-06-08  7:50 ` Rudolf Sykora
2009-06-08  9:35   ` Russ Cox
2009-06-16 11:51     ` roger peppe
2009-06-16 12:00       ` erik quanstrom
2009-06-16 12:43         ` Ethan Grammatikidis
2009-06-16 12:52           ` erik quanstrom
2009-06-16 14:07             ` Russ Cox
2009-06-16 14:40               ` erik quanstrom
2009-06-16 23:00             ` Ethan Grammatikidis
2009-06-16 23:01               ` erik quanstrom
2009-06-17 14:34                 ` Ethan Grammatikidis
2009-06-18 22:54                 ` John Floren
2009-06-18 22:59                   ` erik quanstrom
2009-06-16 15:48           ` Charles Forsyth
2009-06-16 15:31             ` erik quanstrom
2009-06-16 22:57               ` Ethan Grammatikidis
2009-06-16 15:55           ` john
2009-06-16 17:19             ` Tim Newsham
2009-06-16 23:05             ` Ethan Grammatikidis
2009-06-08  9:45   ` Martin Neubauer
2009-06-08 10:40     ` Rudolf Sykora
2009-06-16 18:34 Francisco J Ballesteros

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