Re: OT: Odd Perl (rm?) behavior

2002-06-25 Thread Hubert Chan
> "Alex" == Alex Malinovich <[EMAIL PROTECTED]> writes:

Alex> Using xargs works for me if I use the --quote option for the
Alex> script. But the default behavior still produces \\ instead of a
Alex> single \. Though, as I've said, just letting the script print to
Alex> screen shows only a single \. Any suggestions?

That's strange.  It works for me.  Which shell are you using?  I tried
both tcsh (6.11.00-2.1) and bash (2.05a-12).  xargs from findutils
4.1.7-2.   Hmm.  Maybe your version of xargs doesn't grok escaping?
Does "man xargs" say anything about it?  Mine says:

DESCRIPTION
   This manual page  documents  the  GNU  version  of  xargs.
   xargs  reads  arguments from the standard input, delimited
   by blanks (which can be protected with  double  or  single
   quotes  or a backslash) ...

-- 
Hubert Chan <[EMAIL PROTECTED]> - http://www.uhoreg.ca/
PGP/GnuPG key: 1024D/124B61FA
Fingerprint: 96C5 012F 5F74 A5F7 1FF7  5291 AF29 C719 124B 61FA
Key available at wwwkeys.pgp.net.   Encrypted e-mail preferred.


pgpyRXt6mERFZ.pgp
Description: PGP signature


Re: OT: Odd Perl (rm?) behavior

2002-06-24 Thread Alex Malinovich
On Mon, 2002-06-24 at 23:20, Hubert Chan wrote:
> > "Alex" == Alex Malinovich <[EMAIL PROTECTED]> writes:
> 
> [...]
> 
> Alex> However, if I expand the idea a bit and do:
> 
> Alex> rm -v `ls /mydir |spcgobble.pl`
> 
> It works if you use xargs instead.
> 
> # ls /mydir | spcgobble.pl | xargs rm -v

Using xargs works for me if I use the --quote option for the script. But
the default behavior still produces \\ instead of a single \. Though, as
I've said, just letting the script print to screen shows only a single
\. Any suggestions?

-Alex



signature.asc
Description: This is a digitally signed message part


Re: OT: Odd Perl (rm?) behavior

2002-06-24 Thread Alex Malinovich
On Mon, 2002-06-24 at 23:07, Alex Malinovich wrote:

> However, if I expand the idea a bit and do:
> 
> rm -v `ls /mydir |spcgobble.pl`
> 
> I get error messages for files "the" and "party.txt", even though "rm -v
> the\ party.txt" works just fine.

Whoops. The error messages are for files "the\\" and "party.txt".

-Alex


signature.asc
Description: This is a digitally signed message part


Re: OT: Odd Perl (rm?) behavior

2002-06-24 Thread Hubert Chan
> "Alex" == Alex Malinovich <[EMAIL PROTECTED]> writes:

[...]

Alex> However, if I expand the idea a bit and do:

Alex> rm -v `ls /mydir |spcgobble.pl`

It works if you use xargs instead.

# ls /mydir | spcgobble.pl | xargs rm -v

I guess that the backtick operator doesn't grok escaping and quoting,
which is weird.  I tried both tcsh and bash.

-- 
Hubert Chan <[EMAIL PROTECTED]> - http://www.uhoreg.ca/
PGP/GnuPG key: 1024D/124B61FA
Fingerprint: 96C5 012F 5F74 A5F7 1FF7  5291 AF29 C719 124B 61FA
Key available at wwwkeys.pgp.net.   Encrypted e-mail preferred.


pgp3NHbVTQBPR.pgp
Description: PGP signature


OT: Odd Perl (rm?) behavior

2002-06-24 Thread Alex Malinovich
I've been pounding my head against the wall for the past hour or so
trying to get this figured out to no avail. I wrote a simple Perl script
to convert filenames with spaces into either filenames with spaces
escaped or quoted filenames. While STDOUT produces the expected results,
when the output is fed to another command (namely rm) the results are
odd. First, here's the Perl script in all its "complexity":

-- Perl --

#!/usr/bin/perl

@files = ;

foreach (@files) {
  chomp;
  if ($ARGV[0] ne "--quote") {
$_ =~ s/ /\\ /g;
  }else {
$_ = "\"".$_."\"";
  }
  $_ = $_." ";
}

print @files;

-- End Perl --

If I just do something like:

ls /mydir |spcgobble.pl

I get the proper output. Namely a file called "the party.txt" will come
out as "the\ party.txt" suitable for ingestion by rm.

However, if I expand the idea a bit and do:

rm -v `ls /mydir |spcgobble.pl`

I get error messages for files "the" and "party.txt", even though "rm -v
the\ party.txt" works just fine.

In much the same way, rm -v "the party.txt", works just fine, but using
the --quote option in the script which produces "the party.txt" on
STDOUT, I get an error message about "the not being found and party.txt"
not being found. Any suggestions?

-Alex


signature.asc
Description: This is a digitally signed message part