Set IFS env variable to "" for overlay_text shell expansion
This prevents wordexp function from splitting the output of shell expansion into “words” and, as a consequence, removing the newlines from it. With this commit applied, setting overlay_text = $(echo -e 'hello\nworld!') displays hello world! in Imv window. Without this commit, the same overlay_text setting would display hello world! since wordexp splits the string "hello\nworld!" into two words and connects them with a space. This should not break any of the commands executed in $(), because the IFS variable is *not* inherited by their shell. The commands don't see this change and run with the default IFS value.
This commit is contained in:
parent
9ae3ee1da1
commit
4690692154
|
@ -1979,6 +1979,7 @@ static size_t generate_env_text(struct imv *imv, char *buf, size_t buf_len, cons
|
|||
|
||||
size_t len = 0;
|
||||
wordexp_t word;
|
||||
setenv("IFS", "", 1);
|
||||
if (wordexp(format, &word, 0) == 0) {
|
||||
for (size_t i = 0; i < word.we_wordc; ++i) {
|
||||
len += snprintf(buf + len, buf_len - len, "%s ", word.we_wordv[i]);
|
||||
|
@ -1987,6 +1988,7 @@ static size_t generate_env_text(struct imv *imv, char *buf, size_t buf_len, cons
|
|||
} else {
|
||||
len += snprintf(buf, buf_len, "error expanding text");
|
||||
}
|
||||
unsetenv("IFS");
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue