octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: untar.m on Solaris with non-GNU tar


From: Bill Denney
Subject: Re: untar.m on Solaris with non-GNU tar
Date: Fri, 20 Oct 2006 16:21:22 -0400 (EDT)

On Fri, 20 Oct 2006, John W. Eaton wrote:

On 20-Oct-2006, Bill Denney wrote:

| I'm working on something that will fix this.  It will use the command:
|
| sprintf("(cd \"%s\"; gzip -d -c \"%s\" | tar -x -v)", directory, filename);

Is this to fix the untar command, or for the unpack command?

I was making unpack into a central driver where untar, unzip, gunzip, and bunzip2 could all just pass their input into unpack since the operations are all the same:

validate the input
get the url if needed
execute a command
parse the output to get a file list

Is directory "." unless the optional outputdir argument is given?

Yes.

This will all break unless we have a POSIX shell, since I don't think
the Windows command shell does subshells the same way as a POSIX
shell.

If we care about Windows (and apparently some people do) then we need
to write these kinds of things in portable ways.  Does that mean we
need to do ugly things like

 if (isunix ())
   unix ("...");
 elseif (ispc ())
   dos ("...");
 else
   error ("I have no clue how to execute an external command");
 endif

We can do something like is currently done in untar:

orig_dir = pwd ();

unwind_protect
  chdir (directory);
  [status, output] = system (sprintf ("tar -x -v -f %s", tarfile));
unwind_protect_cleanup
  chdir (orig_dir);
end_unwind_protect

Or we have to decide that the way to achieve portability is to ensure
that Octave has a POSIX shell available to run external commands.  But
even that might not be enough, as filesystem differences may cause
trouble unless we are careful.

I don't think we have to worry about a POSIX shell all the time. I can do the above and it should work. Piping output works in windows, and that's all that's required.

Bill

--
"I could never sleep my way to the top
because my alarm clock always wakes me right up."
  -- "Hey, Mr. DJ...", They Might Be Giants



reply via email to

[Prev in Thread] Current Thread [Next in Thread]