mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 03:36:32 +01:00
next attempt to fix the use of wordexp(3) ...
git-svn-id: svn://localhost/ardour2/branches/3.0@10532 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
46e25db073
commit
ec9b3674df
1 changed files with 16 additions and 14 deletions
|
|
@ -51,6 +51,7 @@
|
||||||
#include "pbd/xml++.h"
|
#include "pbd/xml++.h"
|
||||||
#include "pbd/basename.h"
|
#include "pbd/basename.h"
|
||||||
#include "pbd/strsplit.h"
|
#include "pbd/strsplit.h"
|
||||||
|
#include "pbd/replace_all.h"
|
||||||
|
|
||||||
#include "ardour/utils.h"
|
#include "ardour/utils.h"
|
||||||
#include "ardour/rc_configuration.h"
|
#include "ardour/rc_configuration.h"
|
||||||
|
|
@ -284,23 +285,24 @@ path_expand (string path)
|
||||||
#ifdef HAVE_WORDEXP
|
#ifdef HAVE_WORDEXP
|
||||||
/* Handle tilde and environment variable expansion in session path */
|
/* Handle tilde and environment variable expansion in session path */
|
||||||
string ret = path;
|
string ret = path;
|
||||||
|
string quoted;
|
||||||
wordexp_t expansion;
|
wordexp_t expansion;
|
||||||
|
|
||||||
/* force field expansion to avoid use whitespace, since we know this is
|
|
||||||
* a path
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *oifs = getenv ("IFS");
|
/* wordexp cannot be forced (it appears) into either
|
||||||
setenv ("IFS", "/", 1);
|
|
||||||
int result = wordexp (path.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF);
|
(1) NOT doing field splitting
|
||||||
if (oifs) {
|
(2) splitting based on something other than whitespace
|
||||||
setenv ("IFS", oifs, 1);
|
|
||||||
} else {
|
(despite the documentation claiming that it obeys IFS etc).
|
||||||
unsetenv ("IFS");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (result) {
|
so, quote the most likely spaces to occur in a path, and that should
|
||||||
|
be about as much as we can do.
|
||||||
|
*/
|
||||||
|
|
||||||
|
quoted = path;
|
||||||
|
replace_all (quoted, " ", "\\ ");
|
||||||
|
|
||||||
|
switch (wordexp (quoted.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF)) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case WRDE_NOSPACE:
|
case WRDE_NOSPACE:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue