aboutsummaryrefslogtreecommitdiff
blob: 0a176ebcee61e72792cd782f20d285b603f5e661 (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
/*
   Please use git log for copyright holder and year information

   This file is part of libbash.

   libbash is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 2 of the License, or
   (at your option) any later version.

   libbash is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with libbash.  If not, see <http://www.gnu.org/licenses/>.
*/
gunit java_libbash;

var_def:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
"asdf=(`echo 6` b c d)"-> (= asdf (ARRAY (STRING (COMMAND_SUB `echo 6`)) (STRING b) (STRING c) (STRING d)))
"asdf=(${P} b c d)"->(= asdf (ARRAY (STRING (VAR_REF P)) (STRING b) (STRING c) (STRING d)))
"asdf=($(echo a))" -> (= asdf (ARRAY (STRING (COMMAND_SUB $(echo a)))))
"asdf=(
		--disable-dependency-tracking
		${VAR}
)" -> (= asdf (ARRAY (STRING - - disable - dependency - tracking) (STRING (VAR_REF VAR))))
"asdf=()" -> (= asdf ARRAY)
"asdf+=()" -> (+= asdf ARRAY)
"asdf+=(a)" -> (+= asdf (ARRAY (STRING a)))

var_ref:
"$asdf" -> (VAR_REF asdf)
"${asdf[0]:-default}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL (asdf 0) (STRING default)))
"${asdf[3]}" -> (VAR_REF (asdf 3))
"${asdf[4] }" -> (VAR_REF (asdf 4))
"${asdf[i*2]}" -> (VAR_REF (asdf (* (VAR_REF i) 2))))
"${asdf[1]:2:2}" -> (VAR_REF (OFFSET (asdf 1) 2 2))
"${asdf[2]##word}" -> (VAR_REF (REPLACE_AT_START (asdf 2) (STRING word)))
"${asdf[3]%%word}" -> (VAR_REF (REPLACE_AT_END (asdf 3) (STRING word)))
"${asdf[4]//pattern}" -> (VAR_REF (REPLACE_ALL (asdf 4) (STRING pattern)))
"${asdf}" -> (VAR_REF asdf)
"${#asdf[0]}" -> (VAR_REF (# (asdf 0)))
"${asdf[@]}" -> (VAR_REF (ARRAY asdf @))
"${asdf[*]}" -> (VAR_REF (ARRAY asdf *))
"${#asdf[@]}" -> (VAR_REF (# (asdf ARRAY_SIZE)))
"${#asdf[*]}" -> (VAR_REF (# (asdf ARRAY_SIZE)))
"${asdf[@]:0:1}" -> (VAR_REF (OFFSET (ARRAY asdf @) 0 1))
"${asdf[*]#path}" -> (VAR_REF (LAZY_REMOVE_AT_START (ARRAY asdf *) (STRING path)))
"${asdf[@]%word}" ->  (VAR_REF (LAZY_REMOVE_AT_END (ARRAY asdf @) (STRING word)))
"${asdf[*]/pattern/string}" -> (VAR_REF (REPLACE_FIRST (ARRAY asdf *) (STRING pattern) (STRING string)))