mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
![Zbigniew Jędrzejewski-Szmek](/assets/img/avatar_default.png)
It looks like garbled output… I didn't use shell-escape, because the other characters that are special for the shell that are used in versions should not be escaped.
36 lines
940 B
Bash
Executable file
36 lines
940 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -e
|
|
|
|
ANALYZE="${1:-systemd-analyze}"
|
|
|
|
$ANALYZE compare-versions 1 lt 2
|
|
$ANALYZE compare-versions 1 '<' 2
|
|
$ANALYZE compare-versions 1 le 2
|
|
$ANALYZE compare-versions 1 '<=' 2
|
|
$ANALYZE compare-versions 1 ne 2
|
|
$ANALYZE compare-versions 1 '!=' 2
|
|
( ! $ANALYZE compare-versions 1 ge 2 )
|
|
( ! $ANALYZE compare-versions 1 '>=' 2 )
|
|
( ! $ANALYZE compare-versions 1 eq 2 )
|
|
( ! $ANALYZE compare-versions 1 '==' 2 )
|
|
( ! $ANALYZE compare-versions 1 gt 2 )
|
|
( ! $ANALYZE compare-versions 1 '>' 2 )
|
|
|
|
test "$($ANALYZE compare-versions 1 2)" = '1 < 2'
|
|
test "$($ANALYZE compare-versions 2 2)" = '2 == 2'
|
|
test "$($ANALYZE compare-versions 2 1)" = '2 > 1'
|
|
test "$($ANALYZE compare-versions '' '')" = "'' == ''"
|
|
|
|
set +e
|
|
|
|
$ANALYZE compare-versions 1 2; ret1=$?
|
|
$ANALYZE compare-versions 2 2; ret2=$?
|
|
$ANALYZE compare-versions 2 1; ret3=$?
|
|
|
|
set -e
|
|
|
|
test $ret1 == 12
|
|
test $ret2 == 0
|
|
test $ret3 == 11
|