/* 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 . */ gunit java_libbash; variable_reference: "$asdf" -> (VAR_REF asdf) "${asdf}" -> (VAR_REF asdf) "${asdf:-foo}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))) "${asdf:-=}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING =))) "${asdf:+=}" -> (VAR_REF (USE_ALTERNATE_WHEN_UNSET_OR_NULL asdf (STRING =))) "${asdf:==}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING =))) "${asdf:-public_html}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING public_html))) "${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING 'foo'))) "${asdf:=}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING EMPTY_EXPANSION_VALUE))) "${bar:7}" -> (VAR_REF (OFFSET bar 7)) "${bar: -10}" -> (VAR_REF (OFFSET bar (MINUS_SIGN 10))) "${bar:(-10 + 5)}" -> (VAR_REF (OFFSET bar (+ (MINUS_SIGN 10) 5))) "${foo:5:2}" -> (VAR_REF (OFFSET foo 5 2)) "${foo::2}" -> (VAR_REF (OFFSET foo 0 2)) "${foo:$((5)):$((2))}" -> (VAR_REF (OFFSET foo 5 2)) "${!asdf*}" -> (VAR_REF (! asdf *)) "${!asdf@}" -> (VAR_REF (! asdf @)) "${!asdf[*]}" -> (VAR_REF (LIST_EXPAND asdf *)) "${!asdf[@]}" -> (VAR_REF (LIST_EXPAND asdf @)) "${#foo}" -> (VAR_REF (# foo)) "${foo#bar}" -> (VAR_REF (LAZY_REMOVE_AT_START foo (STRING bar))) "${fo*o#bar}" FAIL "${fo@o#bar}" FAIL "${foo##bar}" -> (VAR_REF (REPLACE_AT_START foo (STRING bar))) "${foo%bar}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING bar))) "${foo%%bar}" -> (VAR_REF (REPLACE_AT_END foo (STRING bar))) "${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; MATCH_ALL))) "${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /))) "${1%& <><<; ();&&|<<<<<()*}" -> (VAR_REF (LAZY_REMOVE_AT_END 1 (STRING & < > << ; ( ) ; && | <<< << ( ) MATCH_ALL))) "${this/is/pattern}"->(VAR_REF (REPLACE_FIRST this (STRING is) (STRING pattern))) //Test positional/special parameters "$1" -> (VAR_REF 1) "$@" -> (VAR_REF @) "$*" -> (VAR_REF *) "${@}" -> (VAR_REF @) "${#}" -> (VAR_REF #) "$#" -> (VAR_REF #) "${!foo}" -> (VAR_REF (VAR_REF foo)) "${!#}" -> (VAR_REF (VAR_REF #)) "${3}" -> (VAR_REF 3) "$?" -> (VAR_REF ?) "$_" -> (VAR_REF _) "${_}" -> (VAR_REF _) "$$" -> (VAR_REF $) "${$}" -> (VAR_REF $) "${PV//./_}" -> (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))) "${PV// }" -> (VAR_REF (REPLACE_ALL PV (STRING ))) "${PV//[-._]/}" -> (VAR_REF (REPLACE_ALL PV (STRING (MATCH_ANY - . _)) (STRING EMPTY_EXPANSION_VALUE))) "${PV/${pattern}/${replace}}" -> (VAR_REF (REPLACE_FIRST PV (STRING (VAR_REF pattern)) (STRING $ { replace }))) "${PV/#foo/bar}" -> (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))) "${PV/%foo/bar}" -> (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))) "${PN/%spaces /more }" -> (VAR_REF (REPLACE_AT_END PN (STRING spaces ) (STRING more ))) "${PN/wrong#/#correct}" -> (VAR_REF (REPLACE_FIRST PN (STRING wrong #) (STRING # correct))) "${a/b/\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING \ } c))) "${a/b/a\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING a \ } c))) "${#var}" -> (VAR_REF (# var)) "${#var[@]}" -> (VAR_REF (# (var ARRAY_SIZE))) "${#var[*]}" -> (VAR_REF (# (var ARRAY_SIZE))) "${#@}" -> (VAR_REF (# @)) "${#*}" -> (VAR_REF (# *)) "${##}" -> (VAR_REF (# #)) "${#$}" -> (VAR_REF (# $)) variable_definition_atom: "MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) "MY_PN=1abc" -> (= MY_PN (STRING 1 abc))