On 08/08/12 23:39, Manuel H wrote:
> Hello!
>
> Currently i'm struggling with creating a portable shell-script out of my
> options-definition file. Here is my options.def file:
>
> [...]
>
> When calling autogen with my definitions-file as only option, AutoGen
> should write the generated shell script to standard output -- if i
> interpret the text in the first paragraph of chapter 7.12.2 of the
> AutoGen manual correctly.
>
> My second attempt was to use getdefs, but this will result in an error:
>
> getdefs input=options.def
"getdefs" is for extracting special markup comments into autogen definitions.
Your "options.def" file is already in autogen definitions format.
So, no, that won't work.
WRT creating a shell script to parse options, perhaps it isn't clear enough.
You must go through several steps:
1. generate C source
2. compile a program that emits the shell script
3. run that program
4. incorporate the resulting output into your script.
That would be:
$ autogen joiner-opts.def
# NOTE: do not use options.def as "options.h" conflicts
# note to self: fix this
$ cc -o gen-joiner-opts -DTEST_JOINER_OPTS joiner-opts.c $(
autoopts-config cflags ldflags)
$ ./gen-joiner-opts -o joiner-opts.sh
$ cat joiner-opts.sh
#! /bin/bash
# # # # # # # # # # -- do not modify this marker --
#
# DO NOT EDIT THIS SECTION OF joiner-opts.sh
#
# From here to the next `-- do not modify this marker --',
# the text has been generated Thursday August 9, 2012 at 07:34:59 AM PDT
# From the JOINER option definitions
#
JOINER_LONGUSAGE_TEXT='joiner - File joiner
USAGE: joiner [ <option-name>[{=| }<val>] ]...
Arg Option-Name Description
Fil basefile The basefile...
no help Display extended usage information and exit
All arguments are named options.'
JOINER_USAGE_TEXT='joiner - File joiner
USAGE: joiner [ <option-name>[{=| }<val>] ]...
Arg Option-Name Description
Fil basefile The basefile...
no help Display extended usage information and exit
All arguments are named options.'
JOINER_BASEFILE=${JOINER_BASEFILE}
JOINER_BASEFILE_set=false
export JOINER_BASEFILE
OPT_ARG=$1
while [ $# -gt 0 ]
do
OPT_ELEMENT=''
OPT_ARG_VAL=''
OPT_ARG=${1}
OPT_CODE=`echo "X${OPT_ARG}"|sed 's/^X-*//'`
shift
OPT_ARG=$1
case "${OPT_CODE}" in *=* )
OPT_ARG_VAL=`echo "${OPT_CODE}"|sed 's/^[^=]*=//'`
OPT_CODE=`echo "${OPT_CODE}"|sed 's/=.*$//'` ;; esac
case "${OPT_CODE}" in
'ba' | \
'bas' | \
'base' | \
'basef' | \
'basefi' | \
'basefil' | \
'basefile' )
if [ -n "${JOINER_BASEFILE}" ] && ${JOINER_BASEFILE_set} ; then
echo Error: duplicate BASEFILE option >&2
echo "$JOINER_USAGE_TEXT"
exit 1 ; fi
JOINER_BASEFILE_set=true
OPT_NAME='BASEFILE'
OPT_ARG_NEEDED=YES
;;
'he' | \
'hel' | \
'help' )
echo "$JOINER_LONGUSAGE_TEXT"
exit 0
;;
[....]
|