Fix parse_line() to support stripping surrounded double-quotes, etc.
return 1
fi
- declare -i i=0
+ declare -i i=0 # Index of the CONFIG_ITEM array
declare -i length=0
declare -i idx=0
- declare -i s_quote_flag=0
- declare -i d_quote_flag=0
+ declare -i s_quote_flag=0 # Flag of the single quote character
+ declare -i d_quote_flag=0 # Flag of the double quotes character
local TMP_LETTER LINE
- LINE=$*
+ LINE="$*"
# Initialize the CONFIG_ITEM array
unset CONFIG_ITEM
else
d_quote_flag=0
fi
-
- if [ ${i} -eq 1 ]; then
- CONFIG_ITEM[i]=${CONFIG_ITEM[i]}"\\"${TMP_LETTER}
- idx=${idx}+1
- continue
- fi
;;
"\r")
idx=${idx}+1
CONFIG_ITEM[i]=${CONFIG_ITEM[i]}${TMP_LETTER}
idx=${idx}+1
done
+
+ # Extract the real value of each field
+ # Remove surrounded double-quotes, etc.
+ for ((idx = 0; idx <= $i; idx++)); do
+ # Strip the leading and trailing space-characters
+ CONFIG_ITEM[idx]=`expr "${CONFIG_ITEM[idx]}" : '[[:space:]]*\(.*\)[[:space:]]*$'`
+
+ # Remove the surrounded double-quotes
+ if [ -z "`echo \"${CONFIG_ITEM[idx]}\"|sed 's/^".*"$//'`" ]; then
+ CONFIG_ITEM[idx]=`echo "${CONFIG_ITEM[idx]}" | sed 's/^"//' | sed 's/"$//'`
+ fi
+
+ CONFIG_ITEM[idx]=`echo "${CONFIG_ITEM[idx]}" | sed 's/""/"/g'`
+ done
+
return 0
}
&& [ "${line_marker}" != "${LV_MARKER}" ] && continue
# Parse the config line into CONFIG_ITEM
- if ! parse_line $LINE; then
+ if ! parse_line "$LINE"; then
return 1
fi
SIXTH_ITEM[idx]=${CONFIG_ITEM[5]}
SEVENTH_ITEM[idx]=${CONFIG_ITEM[6]}
- LVM_NAME[idx]=`echo "${LVM_NAME[idx]}" | sed 's/^"//' | sed 's/"$//'`
- OP_OPTS[idx]=`echo "${OP_OPTS[idx]}" | sed 's/^"//' | sed 's/"$//'`
- SIXTH_ITEM[idx]=`echo "${SIXTH_ITEM[idx]}" | sed 's/^"//' | sed 's/"$//'`
-
# Check some required items
if ! check_lvm_item $idx; then
echo >&2 "`basename $0`: check_lvm_item() error:"\
[ "`echo ${LINE}|awk -F, '{print $2}'`" != "${MD_MARKER}" ] && continue
# Parse the config line into CONFIG_ITEM
- if ! parse_line $LINE; then
+ if ! parse_line "$LINE"; then
return 1
fi
RAID_LEVEL[idx]=${CONFIG_ITEM[5]}
MD_DEVS[idx]=${CONFIG_ITEM[6]}
- OP_OPTS[idx]=`echo "${OP_OPTS[idx]}" | sed 's/^"//' | sed 's/"$//'`
- MD_DEVS[idx]=`echo "${MD_DEVS[idx]}" | sed 's/^"//' | sed 's/"$//'`
-
# Check some required items
if ! check_md_item $idx; then
echo >&2 "`basename $0`: check_md_item() error:"\
fi
if [ -n "${MGS_NIDS[i]}" ]; then
- MGS_NIDS[i]=`echo "${MGS_NIDS[i]}" | sed 's/^"//' | sed 's/"$//'`
mgsnids_str=${MGS_NIDS[i]}
while read mgsnids; do
MKFS_CMD=${MKFS_CMD}$"--mgsnode="${mgsnids}$" "
fi
if [ -n "${FORMAT_OPTIONS[i]}" ]; then
- if [ "${FORMAT_OPTIONS[i]:0:1}" = "\"" ]; then
- FORMAT_OPTIONS[i]=`echo "${FORMAT_OPTIONS[i]}" | sed 's/^"//' | sed 's/"$//'`
- fi
MKFS_CMD=${MKFS_CMD}${FORMAT_OPTIONS[i]}$" "
fi
fi
if [ -n "${FAILOVERS[i]}" ]; then
- FAILOVERS[i]=`echo "${FAILOVERS[i]}" | sed 's/^"//' | sed 's/"$//'`
failnids_str=${FAILOVERS[i]}
while read failnids; do
MKFS_CMD=${MKFS_CMD}$"--failnode="${failnids}$" "
fi
# Parse the config line into CONFIG_ITEM
- if ! parse_line $LINE; then
+ if ! parse_line "$LINE"; then
echo >&2 $"`basename $0`: parse_line() error: Occurred"\
"on line ${line_num} in ${CSV_FILE}: $LINE"
return 1
MOUNT_OPTIONS[idx]=${CONFIG_ITEM[10]}
FAILOVERS[idx]=${CONFIG_ITEM[11]}
+ MODULE_OPTS[idx]=`echo "${MODULE_OPTS[idx]}" | sed 's/"/\\\"/g'`
+
# Check some required items for formatting target
if ! check_item $idx; then
echo >&2 $"`basename $0`: check_item() error:"\