2 ############################################################
4 # author: CottonCandyOwner(CottonCandyOwner@126.com)
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
11 ############################################################
13 # etz is a compressed tar ball file with script code
14 # for self-decompress, and running additional cmd.
15 ############################################################
24 # external sourced cmd.
25 #source <extern-script> --load
32 ##############################
33 # section: public comment info
34 ##############################
38 ##############################
39 # section: variable define
40 ##############################
45 # this comment is used for version id auto update.
52 readonly ETZ_VER_DATE
=20240201
55 readonly ETZ_PROG
=`basename $0`
57 readonly ETZ_PROG_VERSION
="v${ETZ_V1}.${ETZ_V2}\${ETZ_V3:+\".$ETZ_V3\"}\${ETZ_VEXT:+\"$ETZ_VEXT\"}\${ETZ_VER_DATE:+\"-$ETZ_VER_DATE\"}"
58 ETZ_PROG_VERSION_STR
="`eval echo $ETZ_PROG_VERSION`
59 Copyright (C) 2023- Free Software Foundation, Inc.
60 This configure script is free software; the Free Software
61 Foundation gives unlimited permission to copy, distribute
64 Writen by @{SRCPKG_AUTHOR}(@{SRCPKG_AUTHOR_EMAIL}).
67 ETZ_PROG_BANNER
="$ETZ_PROG $ETZ_PROG_VERSION_STR"
68 ETZ_PROG_SYNTAX
='Usage: $ETZ_PROG -[${p_shortparam//\|/}]'
69 ETZ_PROG_DESC
=" zipped-tarball executalbes.
75 @ create executable ziped-tarball.
77 etz -c <filename>[.etz|.zti] <dir>
79 @ decompress executable ziped-tarball, and running script in it.
81 etz -d <filename>[.etz|.zte|.zti]
86 ETZ_USAGE_FMT
='$ETZ_PROG_BANNER
94 # do not delete this comment, it is used for var define code intert.
96 # args-var-define-begin
102 # @ every paramter desc-str-line start with 'param'.
103 # @ every colum start with '|', and seperated by blanks.
104 # @ '|blank' means a blank line dispalyed in helper.
105 # @ follow with a '' quoated string is the option category string.
106 # @ comment '#' in desc-str is also supported, and can be used to
107 # disable some option have not been implemented.
108 # @ desc-str can be in multiple var. and some of them maybe re-used
109 # for other program by 'source xxx --loadshlib'.
112 |prog $0 'this file is an demo or template for utility cmd shell script program.'
115 # @ PARAMETER DEFINE.
116 # this desc str would be referenced in scripttest, consider about opt name space.
117 # =, param name for opt.
118 # %, var name if this opt is enabled.
119 # &, proc func if opt trigged.
121 |prog $0 'project build util-program.'
123 |blank '[etz-category]'
124 |param |-c |-- |--- |=<file> |%<shortopt> |&<on_compress> |'compress to file.'
125 |param |-d |-- |--- |=<file> |%<shortopt> |&<on_decompress> |'decompress compressed file and running.'
126 #|param |- |-- |---subcmd |= |%<subcmd> |&<on_subcmd> |'subcmd demo.'
127 #|param |- |-- |---longopt |=<file> |%<longopt> |&<on_longopt> |'long option demo.'
134 |blank 'Version & Helper & Debug:'
135 |param |- |-- |---version |= |%<version> |&<on_version> |'output version info of this program.'
136 |param |- |--help |---help |= |%<help> |&<on_help> |'this helper text doc.'
139 # zte header script content
151 which tar || echo "tar is not installed." >&2 && exit
152 which $DECOMPTYPE || echo "$DECOMPTYPE is not installed." >&2 && exit
154 dd if="$0" conv=skip_bytes skip=$COFFSET ibs=1 count=$CSIZE obs=2k | tar -$DECOMPOPT -
156 dd if="$0" conv=skip_bytes skip=$DOFFSET ibs=1 count=$DSIZE obs=2k | tar -$DECOMPOPT -
163 ##############################
164 # section: private function
165 ##############################
169 # fsyntax: on_codegen
170 # fdesc: on codegen sub-cmd.
179 # fdesc: on subcmd sub-cmd.
188 # fsyntax: on_longopt
189 # fdesc: on longopt sub-cmd.
198 # fsyntax: on_shortopt
199 # fdesc: on shortopt sub-cmd.
208 # fsyntax: on_version
209 # fdesc: on version sub-cmd.
213 eval echo "$ETZ_PROG_VERSION"
220 # fdesc: on help sub-cmd.
224 [[ -z $term_width ]] && term_width
=80
226 helper
="$(opt_helper)"
228 eval ETZ_PROG_SYNTAX
="\"$ETZ_PROG_SYNTAX\""
229 eval echo -ne "\"$ETZ_USAGE_FMT\""
236 ##############################
237 # section: public function
238 ##############################
244 [[ "$@" =~
'--load' ]] && return
249 # prog_opt_dispatch "$@"
250 opt_desc_str_dispatch etz_desc_hdr_str
251 opt_desc_str_dispatch etz_desc_str
252 opt_desc_str_dispatch etz_other_desc_str
255 init_dbglogout
2 testing
20000
256 # set_output_prefix info ""
259 # SRCPKG_DIR="$(pwd)"
260 # TEST_DIR_STR_FMT="$(attr_get catalog::testdir::STR_FMT)"
264 # running action list function for options after init.
265 # the paramter for init will be effact, then execute the
273 if [[ "$@" =~
"--debug" ]]; then
274 declare -g DBGOUTD_OUTPUT
=1
276 # does not need to shift args if the --debug option is not the
277 # first option. it will be ignore in process.
281 if [[ $1 != "--loadshlib" ]]; then
289 ##############################
291 ##############################