summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-11-10 19:00:54 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-11-10 19:00:54 +0000
commit80ec3fb37e0156cf02a25e9b353879819b66057d (patch)
treeceae523083e01837b99ea24a95ef5fbd9c6c686a /libs/ardour/utils.cc
parentbcf500a3512785380bf7d5dcfe1cfe048a75ec28 (diff)
force IFS=/ when calling path_expand, so that whitespace in paths doesn't cause wordexp() to get the wrong idea
git-svn-id: svn://localhost/ardour2/branches/3.0@10530 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 63125ed8cb..c1192c4fe1 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -25,6 +25,7 @@
#include <cstdio> /* for sprintf */
#include <cstring>
+#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
@@ -285,9 +286,27 @@ path_expand (string path)
string ret = path;
wordexp_t expansion;
- switch (wordexp (path.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF)) {
+
+ /* 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");
+ }
+
+ switch (result) {
case 0:
break;
+ case WRDE_NOSPACE:
+ /* see docs on wordexp() */
+ wordfree (&expansion);
+ /* fallthru */
default:
error << string_compose (_("illegal or badly-formed string used for path (%1)"), path) << endmsg;
goto out;