diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-08-27 21:52:57 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-08-29 07:53:59 +1000 |
| commit | 68aba9e353961ccae17183ccdc65c3c89bdcd6c6 (patch) | |
| tree | d8930ba60ce8a3da06d31e7e1b9ea687f08ca866 /src/string_utils.hh | |
| parent | 373858f9bfb50fe2c5670beffbfe63654cc12314 (diff) | |
Use shell specific quoting for env vars
Add a test case to validate roundtrips between Kakoune and the
shell.
Diffstat (limited to 'src/string_utils.hh')
| -rw-r--r-- | src/string_utils.hh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/string_utils.hh b/src/string_utils.hh index 558ba62f..92714a0d 100644 --- a/src/string_utils.hh +++ b/src/string_utils.hh @@ -135,6 +135,23 @@ inline String quote(StringView s) return format("'{}'", double_up(s, "'")); } +inline String shell_quote(StringView s) +{ + return format("'{}'", replace(s, "'", R"('\'')")); +} + +enum class Quoting +{ + Kakoune, + Shell +}; + +inline auto quoter(Quoting quoting) +{ + return quoting == Quoting::Kakoune ? "e : &shell_quote; +} + + } #endif // string_utils_hh_INCLUDED |
