code repo connnect test
[shlib.git] / bin / shlibopt
blobe3e52cacecbc27fbdf5e20e7ce95ce48c792a78f
1 #!/bin/bash
2 ############################################################
3 # source: shlib
4 # author: devenkong(18151155@qq.com)
5 # date: 2022-03-13
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
10 # and modify it.
11 ############################################################
12 # note:
13 # shlib option program. if this cmd is used for set global
14 # paramters, use 'source shlibopt' instead of single shlibopt.
15 ############################################################
18 # todoļ¼š
19 # @
20 # @
23 . shlibinc
25 include stdio.shlib
28 ##############################
29 # section: public comment info
30 ##############################
35 ##############################
36 # section: variable define
37 ##############################
42 ##############################
43 # section: private function
44 ##############################
49 ##############################
50 # section: public function
51 ##############################
54 shlibopt_usage='
55 syntax: shlibopt [option] <paramter>
56 description: set paramters for shlib using.
58 -g get shlib path.
59 -a <path> append path to shlib path.
60 -d [N] delete the N th path item. zero or none paramter delete
61 the latest path in shlib path.
63 -l list shlib files in include path.
64 -i <file> install file to shlib path.
65 -u <file> uninstall file from shlib path.
67 -b init shlib on system boot.
68 -s <user> init shlib on session init.
69 -p init shlib on program start.
71 -v print shlib version info.
72 -h helper information.
78 # main <eval-str>
80 main ()
82 local varin=$1
83 local varout=$2
84 local tmp
86 init_dbglogout 2 shlibopt 20000
89 # args dispatch
91 while getopts :ga:d:li:u:bspvh opt; do
92 eval optstr=\${$OPTIND}
94 case "$opt" in
96 get_shlib_path
99 echo "OPTIND=$OPTIND"
100 echo "optstr=$optstr"
101 add_shlib_path "$2"
102 shift
105 del_shlib_path "$1"
106 shift
110 get_shlib_path | while read line; do
111 echo -ne "\033[32m[$line]\n\033[0m"
112 find $line/* | grep -E "\.shlib"
113 done
116 tmp=( $(get_shlib_path) )
117 cp $2 $tmp
120 tmp=( $(get_shlib_path) )
121 ls $tmp
122 rm $tmp/$2
126 if [[ -z "$(cat $ROOTFS/etc/bash.bashrc | grep -E '. shlibinc')" ]]; then
127 echo ". shlibinc" > $ROOTFS/etc/bash.bashrc
131 if [[ -z "$(cat $ROOTFS/home/$user/.bashrc | grep -E '. shlibinc')" ]]; then
132 echo ". shlibinc" > $ROOTFS/home/$user/.bashrc
140 info "shlib v$SHLIB_VERSION"
143 info "$shlibopt_usage"
146 warn "does not use '-$opt' opt.\n"
148 esac
150 shift
151 done
155 main "$@"
157 ##############################
158 # section: file tail
159 ##############################