I am trying to pass parameters to a script which will accept them in array.
First parameter is where_clause
second parameter is "SRC_TYPE='SYBASE' and PROCESS_CD='BRK'"
[$ cat abcd.ksh
set -x
set -A arg_list -- $*
echo ${arg_list[1]}
echo $2
$ ./abcd.ksh where_clause "SRC_TYPE='SYBASE' and PROCESS_CD='BRK'"
+ set -A arg_list -- where_clause SRC_TYPE=$'\'SYBASE\'' and PROCESS_CD=$'\'BRK\''
+ echo SRC_TYPE=$'\'SYBASE\''
SRC_TYPE='SYBASE'
+ echo SRC_TYPE=$'\'SYBASE\'' and PROCESS_CD=$'\'BRK\''
SRC_TYPE='SYBASE' and PROCESS_CD='BRK'
When echoing $1 $2 etc , it displays correctly, But when assigned to an array it splits the parameters with space.
Can some one help me to modify the code to assign the second variable with single quotes and spaces as the second element of the array
--- Post updated at 04:35 PM ---
Found the solution after more research. Pasting here for reference
used
set -A arg_list -- "$@"
instead of
set -A arg_list -- $*
Out put looks like below
./abcd.ksh where_clause "SRC_TYPE='SYBASE' and PROCESS_CD='BRK'"
+ set -A arg_list -- where_clause SRC_TYPE=$'\'SYBASE\' and PROCESS_CD=\'BRK\''
+ echo SRC_TYPE=$'\'SYBASE\'' and PROCESS_CD=$'\'BRK\''
SRC_TYPE='SYBASE' and PROCESS_CD='BRK'
+ echo SRC_TYPE=$'\'SYBASE\'' and PROCESS_CD=$'\'BRK\''
SRC_TYPE='SYBASE' and PROCESS_CD='BRK'