diff options
author | Seraphime Kirkovski <kirkseraph@gmail.com> | 2016-08-31 21:06:57 +0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-08-31 20:06:57 +0200 |
commit | 07b0b339d6a818fd7aa71beecba8ffbd36d59a8f (patch) | |
tree | 9eeef526c77d0cab13831b72c957cdde698674bc /src/basic/string-util.h | |
parent | c7440e7401461a4bc668f5dae5b1861ed26b85dd (diff) |
machinectl: split OS field in two; print ip addresses (#4058)
This splits the OS field in two : one for the distribution name
and one for the the version id.
Dashes are written for missing fields.
This also prints ip addresses of known machines. The `--max-addresses`
option specifies how much ip addresses we want to see. The default is 1.
When more than one address is written for a machine, a `,` follows it.
If there are more ips than `--max-addresses`, `...` follows the last
address.
Diffstat (limited to 'src/basic/string-util.h')
-rw-r--r-- | src/basic/string-util.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h index b75aba63c2..d029d538bd 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -70,6 +70,10 @@ static inline const char *empty_to_null(const char *p) { return isempty(p) ? NULL : p; } +static inline const char *strdash_if_empty(const char *str) { + return isempty(str) ? "-" : str; +} + static inline char *startswith(const char *s, const char *prefix) { size_t l; |