> ifs='
> ' for (old in `{9 ls *.$EXT}) {

i think ls and the temporary file are getting in the 
way.  if you use globbing and execing directly from
the shell you can avoid quoting problems.  for example,

        for(old in *^' '^*.$EXT)
                ifs=$nl mv $old `{echo $old | sed 's/ //g'}

and now for a digression ....

this looks like c programming to me.  unfortunately
mv doesn't take pairs, so we can't get rid of the for
loop, but we can generate parallel lists.

i'm going to assume that ☺ isn't in any of your file names.
you could pick something else.

the trick here is to paste ☺ onto the end of every list
element.  that way we know that '☺ ' are end-of-token
markers, and other spaces are just spaces.  then we
can delete the spaces without ☺s, then delete the ☺s
and then turn the remaining spaces (they mark the
end of a token) into newlines.

i'm going to assume that $ext also contains the '.'.

        old = *^' '^*$ext
        ifs=$nl new = `{echo $old^☺ | sed 's/([^☺]) /\1/g
                s/☺//g
                s/ /\n/g' }

(the last two sed steps are combinable; s/☺ /\n/g.)

now that we have this, we can

        while(! ~ $#new 0){
                mv $old(1) $new(1)
                old=$old(2-)
                new=$new(2-)
        }

this reminds me, the whole ifs thing is awkward because
it applies for the whole command which is almost never
what you want.  i modified rc to allow one to specify a
backquote splitter.  e.g.

        new = `$nl {echo $old^☺ | sed 's/([^☺]) /\1/g
                s/☺//g
                s/ /\n/g' }

- erik

Reply via email to