summaryrefslogtreecommitdiff
path: root/test/manual/indent/shell.sh
blob: 5b3fb0e66fbddfe39bf70cab8dd52a43dd4e603e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/sh
# -*- eval: (bug-reference-mode 1) -*-

setlock -n /tmp/getmail.lock && echo getmail isn\'t running

toto=$(grep hello foo |
           wc)

myfun () {
    for ((it=0; it<${limit}; ++it))
    {
	echo "whatever $it"
    }
}

# adsgsdg

if foo; then
    if bar; then
	toto
    fi
fi                              # bug#15613

case $X in
    foo)
        do_something
        ;;
    arg=*)			# bug#12953
        do_something_else_based_on_arg
        ;;
    *)
        default
        ;;
esac

{				# bug#17621
    foo1 &&
	foo2 &&
        bar

    foo1 &&     \
        foo2 && \
        bar
}

for foo in bar; do              #  bug#17721
    [ -e $foo ] && {
        echo t
    } && {
	echo r
    }
done

for foo in bar; do              # bug#17896
    [ -e $foo ] && [ -e $bar ] && {
        echo just fine thanks
    }
done

filter_3 ()                     # bug#17842
{
    tr -d '"`' | tr '	' ' ' | \
        awk -F\; -f filter.awk | \
	grep -v "^," | sort -t, -k2,2
}

foo | bar | {
    toto
}

grep -e "^$userregexp:" /etc/passwd | cut -d :  -f 1 | while read user ; do
    print -u2 "user=$user"      # bug#18031
    sudo -U $user -ll | while read line ; do
        :
    done
done

echo -n $(( 5 << 2 ))
# This should not be treated as a heredoc (bug#12770).
2

foo='bar<<'                     # bug#11263
echo ${foo%<<aa}                # bug#11263
echo $((1<<8))                  # bug#11263
echo $[1<<8]                    # bug#11263

declare -a VERSION
for i in $(ls "$PREFIX/sbin") ; do
    echo -e $N')' $i
    VERSION[${#VERSION[*]}]=$i  # bug#11946.
    N=$(($N + 1))
done

foo () {

    bar () {
        blilbi
    }

    case toto
    in a) hello                 # KNOWN INDENT BUG
    ;; b) hi                    # KNOWN INDENT BUG
    ;; c) hi                    # KNOWN INDENT BUG
    esac

    case $toto in
        a) echo 1;; b) echo 2;;
        (c)
            echo 3;;
        d)
            echo 3;;
    esac

    case $as_nl`(ac_space=' '; set) 2>&1` in #(
        *${as_nl}ac_space=\ *)
            # `set' does not quote correctly, so add quotes: double-quote
            # substitution turns \\\\ into \\, and sed turns \\ into \.
            sed -n \
	        "s/'/'\\\\''/g;
                 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=/\\1=''/p"
            ;; #(
        *)
            # `set' quotes correctly as required by POSIX, so do not add
            # quotes.
            sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
            ;;
    esac |
        grep '.' |              # KNOWN INDENT BUG
        sed 1d

    case toto in
        -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
            | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* \
            | --exec=* | --exe=* | --ex=*)
            exec_prefix=$ac_optarg ;;
        5)
            hello ;;
        3) hello $(adfad)
           echo esac ;;         # KNOWN INDENT BUG
        5) hello ;;
        4) hello ;&
        4) hello ;;&
        4) hello ;|
        5) hello ;;
        5) hello ;;
    esac

    echo "'" wfgfe

    #!/bin/bash
    cat << EOF \
        | cat sadfsafd \
              sadfsafd           "KNOWN INDENT BUG" \
        | tee -a bug.txt
asdfsaf
This is a test case for a bug in bash shell mode text highlighting
EOF

    cat <<EOF1 <<EOF2           # KNOWN INDENT BUG
help1
EOF1
help2
EOF2
}
bar () {
    if [ $# -eq 0 ]; then
        while
            f                   # KNOWN INDENT BUG
        do
            bla;
        done
        echo "Highlighting is screwed up now"
        if [ 1 = 1 ]; then
            # adsgsdg
            echo "screwed up"
        fi

        $@ $? $#

        for f in *
        do
            sdfg
        done

        if swrgfef
        then blas
        else sdf
        fi

    fi
}