help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] safe parsing of configuration files?


From: adrelanos
Subject: Re: [Help-bash] safe parsing of configuration files?
Date: Tue, 07 May 2013 06:57:12 +0000

John Kearney:
> you could do something like
>
>
>   ks_val_ChkName() {
>     case "${1:?Missing Variable Name}" in
>       [!a-zA-Z_]* | *[!a-zA-Z_0-9]* | '' ) return 3;;
>     esac
>   }
>     ks_val_Set() {
>         ks_val_ChkName "${1}" || return $?
>         eval "${1}"'="${2}"'
>     }
>   ks_cgf_Src() {
>     local IFS=$'\n'
>     local LC_COLLATE=C
>     local cline_tmp
>     local vval_tmp
>     while read -d '' cline_tmp ; do
>       case "${cline_tmp}" ; in
>         \#* | '') continue;;  # skip empty lines and commented lines
>         [a-zA-Z_]*=*)     # *[![:space:]]*) # non empty lines
>           vval_tmp="${cline_tmp#*=}"
>           vval_tmp="${vval_tmp#["']}"
>           vval_tmp="${vval_tmp%["']}"
>           ks_val_Set "${cline_tmp%%=*}" "${vval_tmp}" || echo "error
> '${cline_tmp}'"
>           ;;
>         *)echo "skipping '${cline_tmp}'"
>           continue;;
>       esac
>     done
>   }

I get a error.
./extest: line 18: syntax error near unexpected token `;'
./extest: line 18: `      case "${cline_tmp}" ; in'

Since this has been said to be impossible with bash, you could polish it
a bit please and perhaps put it on github?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]