[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace
From: |
Carnë Draug |
Subject: |
[Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace |
Date: |
Mon, 29 Feb 2016 18:38:53 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.6.0 |
Follow-up Comment #9, bug #47232 (project octave):
The suggested fix of adding quotes to support spaces, will still cause issues
if the filename has quotes.
While system() does not accept a list of arguments to avoid the shell, exec
does. The following works for me.
- rootdir = tilde_expand (rootdir);
+ zipfile = make_absolute_filename (zipfile);
+ files = glob (files);
- zipfile = make_absolute_filename (zipfile);
-
- cmd = sprintf ("zip -r %s %s", zipfile, sprintf (" %s", files{:}));
-
- origdir = pwd ();
- cd (rootdir);
- [status, output] = system (cmd);
- cd (origdir);
-
- if (status)
- error ("zip: zip failed with exit status = %d", status);
+ [pid, msg] = fork ();
+ if (pid < 0)
+ error ("zip: unable to fork in prepartion to call zip");
+ elseif (pid == 0)
+ cd (tilde_expand (rootdir));
+ dup2 (fopen ("/dev/null", "w"), stdout);
+ err = exec ("zip", {"-r", zipfile, files{:}});
+ exit (err);
+ else
+ [pid, status, msg] = waitpid (pid);
+ if (pid < 0)
+ error ("zip: failed to exec zip (exit code %i): %s", status, msg);
+ endif
It has the following issues though:
0 I'm guessing "/dev/null" is not portable
0 when I force exec() to fail, it never exits
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?47232>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Andreas Weber, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Andreas Weber, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Rik, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Andreas Weber, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Rik, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Rik, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Andreas Weber, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Carnë Draug, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Rik, 2016/02/23
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace,
Carnë Draug <=
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Rik, 2016/02/29
- [Octave-bug-tracker] [bug #47232] zip fails if filename has whitespace, Carnë Draug, 2016/02/29