diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-20 19:47:55 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-21 16:32:54 +0200 |
commit | e839ebe5511028f6032ae53ebb43601c1f4624be (patch) | |
tree | f5885697af2295477c99427077af87435431af36 /man/check-os-release.sh | |
parent | man: reorder fields in os-release (diff) | |
download | systemd-e839ebe5511028f6032ae53ebb43601c1f4624be.tar.xz systemd-e839ebe5511028f6032ae53ebb43601c1f4624be.zip |
man: add an example how to correctly read os-release in shell
This is not entirely obvious.
The logic of how to interpret the fields applies in any language, so drop the
pointless mention of C or shell.
Diffstat (limited to 'man/check-os-release.sh')
-rw-r--r-- | man/check-os-release.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/man/check-os-release.sh b/man/check-os-release.sh new file mode 100644 index 0000000000..2a1a057928 --- /dev/null +++ b/man/check-os-release.sh @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release' +. "${os_release}" + +echo "Running on ${PRETTY_NAME:-Linux}" + +if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE:-}" = "debian" ]; then + echo "Looks like Debian!" +fi |