summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-11-10 21:02:14 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-11-10 21:02:14 +0000
commitec9b3674dff8583bcca89bd13179a795bc537c25 (patch)
treedaaa63615124a09df721e792f8e1bd733ab61d8f /libs/ardour/utils.cc
parent46e25db073834ca66c410808c96e3b4180df860f (diff)
next attempt to fix the use of wordexp(3) ...
git-svn-id: svn://localhost/ardour2/branches/3.0@10532 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc30
1 files changed, 16 insertions, 14 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index c1192c4fe1..3c6963bbc1 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -51,6 +51,7 @@
#include "pbd/xml++.h"
#include "pbd/basename.h"
#include "pbd/strsplit.h"
+#include "pbd/replace_all.h"
#include "ardour/utils.h"
#include "ardour/rc_configuration.h"
@@ -284,23 +285,24 @@ path_expand (string path)
#ifdef HAVE_WORDEXP
/* Handle tilde and environment variable expansion in session path */
string ret = path;
-
+ string quoted;
wordexp_t expansion;
-
- /* force field expansion to avoid use whitespace, since we know this is
- * a path
- */
- char *oifs = getenv ("IFS");
- setenv ("IFS", "/", 1);
- int result = wordexp (path.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF);
- if (oifs) {
- setenv ("IFS", oifs, 1);
- } else {
- unsetenv ("IFS");
- }
+ /* wordexp cannot be forced (it appears) into either
+
+ (1) NOT doing field splitting
+ (2) splitting based on something other than whitespace
+
+ (despite the documentation claiming that it obeys IFS etc).
+
+ 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 (result) {
+ switch (wordexp (quoted.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF)) {
case 0:
break;
case WRDE_NOSPACE: