[systemd-devel] systemctl escaping of unit names

Michael Biebl mbiebl at gmail.com
Sun Jul 6 14:46:59 PDT 2014


2014-07-06 23:22 GMT+02:00 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>:
> On Sun, Jul 06, 2014 at 10:28:55PM +0200, Michael Biebl wrote:
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +
>> +#include "log.h"
>> +#include "unit-name.h"
>> +
>> +int main(int argc, char *argv[]) {
>> +        char *escaped_name = NULL;
>> +
>> +        if (argc != 2) {
>> +                log_error("This program requires on argument.");
> "an" or "one"?

Ah, right. Thanks for spotting that typo.

>
>> +                return EXIT_FAILURE;
>> +        }
>> +
>> +        escaped_name = unit_name_escape(argv[1]);
>> +
>> +        if (!escaped_name) {
>> +                log_error("Failed to escape name.");
> Maybe just log_oom()?

Ok.

>> +                return EXIT_FAILURE;
>> +        }
>> +
>> +        printf("%s", escaped_name);
>> +
>> +        return EXIT_SUCCESS;
>
> What about adding a --template parameter, to be used as
>
>    systemd-escape --template myunit at .service /some/path -> myunit at some-path.service

Why not. Let me add that including a short man page.


Cheers,
Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?


More information about the systemd-devel mailing list