"open" will most likely do the same thing
(ahem) You mean you won't even try it? Pull down the "shloop"
utility I referred to earlier, and try this (I just did):
echo '?*;&'
(just to convince you that using single-quotes around a
nasty string will help for some cases -- so long as the string doesn't
include any single-quote characters) And then try this:
mkdir /tmp/junk
echo '?*;&' | shloop -e "touch '/tmp/junk/\i'"
ls -l /tmp/junk
If that doesn't work for you, please let me know. I don't
have access to a FreeBSD system, and I'd be interested to
learn how different it could be from linux & solaris
(where this works).
BTW, if your list of potential file names does happen to
involve cases that include one or more quote-like characters, then
you're right -- the above will not work. In such cases,
let me suggest that you should only be facing this issue with existing
file names that are created by other processes and are
to be used as input to a given pipeline -- don't ever
create such file names yourself for output. To handle
these, open the the nasty-named file for input in perl (get
the file name via "readdir" so you don't need
to present such a name as a command-line arg -- who knows,
maybe a file name could include a "\n"!), then open your
pipeline as a file handle, and pass file data to the pipeline
that way. E.g.:
opendir( DIR, "some_dir" );
@files = grep /[^.]/, readdir( DIR ); # skips "." and ".."
# (assumes you never need to look for files named "...")
foreach $file ( @files ) {
next unless ( -f $file );
$outfile = "something_sane";
open( PIPE, "| $prog1 | $prog2 -x -y | $prog3 > $outfile" );
open( IN, "<", $file );
while (<IN>) {
print PIPE;
}
close PIPE;
close IN;
# and/or unlink or rename that input file so it's less of a bother hen
+ceforth
}
I haven't tried that yet (but I think you should try it
yourself before you say it won't work... ;^).