diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-07-31 16:21:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-09 09:34:55 +0200 |
commit | 0645b83a40d1c782f173c4d8440ab2fc82a75006 (patch) | |
tree | 03c9733aec1d24b4ae6578c14f8ef01b107a6900 /src/udev/udev-builtin.c | |
parent | d59d954d7f6f5f3772b12e8078875183e0b27889 (diff) | |
download | systemd-0645b83a40d1c782f173c4d8440ab2fc82a75006.tar.gz |
tree-wide: replace strv_split_full() with strv_split_extract() everywhere
Behaviour is not identical, as shown by the tests in test-strv.
The combination of EXTRACT_UNQUOTE without EXTRACT_RELAX only appears in
the test, so it doesn't seem particularly important. OTOH, the difference
in handling of squished parameters could make a difference. New behaviour
is what both bash and python do, so I think we can ignore this corner case.
This change has the following advantages:
- the duplication of code paths that do a very similar thing is removed
- extract_one_word() / strv_split_extract() return a proper error code.
Diffstat (limited to 'src/udev/udev-builtin.c')
-rw-r--r-- | src/udev/udev-builtin.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index b41fbfc39a..ac443d66e6 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -109,6 +109,7 @@ UdevBuiltinCommand udev_builtin_lookup(const char *command) { int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command, bool test) { _cleanup_strv_free_ char **argv = NULL; + int r; assert(dev); assert(cmd >= 0 && cmd < _UDEV_BUILTIN_MAX); @@ -117,9 +118,10 @@ int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command if (!builtins[cmd]) return -EOPNOTSUPP; - argv = strv_split_full(command, NULL, SPLIT_QUOTES | SPLIT_RELAX); - if (!argv) - return -ENOMEM; + r = strv_split_extract(&argv, command, NULL, + EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_RETAIN_ESCAPE); + if (r < 0) + return r; /* we need '0' here to reset the internal state */ optind = 0; |