mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC3012 (markdown)
@@ -18,11 +18,11 @@ First, make sure you wanted a lexicographical comparison (aka dictionary order),
|
|||||||
|
|
||||||
Then to compare as string, you can use `expr` and make sure that the strings are not interpreted numerically by adding some non-numerical data to them. Here, an apostrophe is prepended:
|
Then to compare as string, you can use `expr` and make sure that the strings are not interpreted numerically by adding some non-numerical data to them. Here, an apostrophe is prepended:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
x="aardvark"
|
x="aardvark"
|
||||||
y="zebra"
|
y="zebra"
|
||||||
if expr "'$x" \< "'$y" > /dev/null
|
if expr "'$x" \< "'$y" > /dev/null
|
||||||
then
|
then
|
||||||
echo "$x comes before $y in the dictionary"
|
echo "$x comes before $y in the dictionary"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user