20230322
[shlib.git] / doc / example / gplib / var-func-valid-judgement
blobab549e2974be106373cdca860d3ce997198e98de
2 #!/bin/bash
3 ############################################################
4 # source: shlib
5 # author: devenkong(18151155@qq.com)
6 # date: 2022-07-29
7 ############################################################
8 # Copyright (C) 2022- Free Software Foundation, Inc.
9 # This configure script is free software; the Free Software 
10 # Foundation gives unlimited permission to copy, distribute 
11 # and modify it.
12 ############################################################
13 # note:
14 #     judgement for var/func/alias if it is defined.
15 ############################################################
18 # todoļ¼š
19 # @ 
20 # @ 
23 . shlibinc
26 ##############################
27 # section: shlib include
28 ##############################
30 include gplib.shlib
31 include stdio.shlib
34 ##############################
35 # section: public comment info
36 ##############################
41 ##############################
42 # section: variable define
43 ##############################
48 ##############################
49 # section: private function
50 ##############################
55 ##############################
56 # section: public function
57 ##############################
59 func abc [ int a, int b, c ]
61         echo aaa
62         {
63                 echo param a = $a
64                 echo param b = $b
65                 echo param c = $c
66         }
67         dreturn "this string is return from function abc()."
71 alias testalias="ls"
76 # main <eval-str>
78 main ()
80         local testvar=aaa
81         echo "func-paramter:"
82         
83         echo xxxxxxxxxxxxxxxxxxxxxxxxx
84         
85         [[ $(is_digital 123) == true ]] && echo "string '123' is a digial string."
86         [[ $(is_digital 123) == false ]] && echo "string 'a123' is a digial string."
87         
88         [[ $(is_var_defined testvar) == true ]] && echo "string 'testvar' is a variable."
89         [[ $(is_var_defined testvar) == false ]] && echo "variable 'testvar' is not defined."
90         
91         [[ $(is_func_defined abc) == true ]] && echo "string 'abc' is a function name string."
92         [[ $(is_func_defined aaa) == false ]] && echo "string 'aaa' is not a function name string."
93         
94         
95         [[ $(is_alias_defined testalias) == true ]] && echo "string 'testvar' is a defined alias name."
96         [[ $(is_alias_defined testalias) == false ]] && echo "string 'testalias' is not a defined alias name."
97         
98         echo xxxxxxxxxxxxxxxxxxxxxxxxx
102 main "$@"
104 ##############################
105 # section: file tail
106 ##############################