fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

kertyFix grep regex in test locale-numeric.fish4ce8037e7

master
1.2 KiB37 linesraw
1# RUN: %fish %s
2# musl currently does not have a `locale` command, so we skip this test there.
3# REQUIRES: command -v locale
4# We need a comma-using locale we know.
5# REQUIRES: locale -a | grep -Ei '(bg_BG|de_DE|es_ES|fr_FR|ru_RU)\.(UTF-8|utf8)'
6# OpenBSD does not use LC_NUMERIC, this test is pointless there.
7# REQUIRES: test "$(uname)" != OpenBSD
8
9set -l locales (locale -a)
10set -l acceptable_locales bg_BG de_DE es_ES fr_FR ru_RU
11set -l numeric_locale
12for locale in {$acceptable_locales}.{UTF-8,UTF8}
13    if string match -i -q $locale $locales
14        set numeric_locale $locale
15        break
16    end
17end
18
19if not set -q numeric_locale[1]
20    # Note we tried to check for a locale above,
21    # but in case this fails because of e.g. case issues,
22    # let's error again.
23    echo Please install one of the following locales: >&2
24    printf '%s\n' $acceptable_locales".utf-8" >&2
25    exit 127
26end
27
28begin
29    set -x LC_NUMERIC $numeric_locale
30    printf '%e\n' "3,45" # should succeed, output should be 3,450000e+00
31    # CHECK: 3,450000e+00
32    printf '%e\n' "4.56" # should succeed, output should be 4,560000e+00
33    # CHECK: 4,560000e+00
34
35    # This should succeed without output
36    test 42.5 -gt 37.2
37end