Introduce shell_expand

This performs shell expansion without field splitting. This fixes issues with
filenames containing spaces.

This commit also cleans up complicated logic to join fields and to set
XDG_CONFIG_HOME.
This commit is contained in:
emersion 2018-12-10 23:20:27 +01:00
parent 6acbe84fdd
commit 8389047b47
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
8 changed files with 121 additions and 114 deletions

14
include/shexp.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef _SWAY_SHEXP_H
#define _SWAY_SHEXP_H
#include <stdbool.h>
/**
* Takes a pointer to a string and reallocates it with the result of its shell
* expansion. Undefined environment variables are considered as errors. Returns
* true if it succeeds, otherwise returns false, leaving the original string
* unchanged.
*/
bool shell_expand(char **path);
#endif