From: yujian Date: Mon, 17 Jul 2006 02:24:06 +0000 (+0000) Subject: b=9853 X-Git-Tag: v1_7_0_51~2^13~5^2~14 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b20250db9e1d0085d080402758143114b8e4996f;p=fs%2Flustre-release.git b=9853 Fix parse_line() to support stripping surrounded double-quotes, etc. --- diff --git a/lustre/scripts/lc_common.sh b/lustre/scripts/lc_common.sh index 36781c0..2418778 100644 --- a/lustre/scripts/lc_common.sh +++ b/lustre/scripts/lc_common.sh @@ -115,14 +115,14 @@ parse_line() { 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 @@ -159,12 +159,6 @@ parse_line() { else d_quote_flag=0 fi - - if [ ${i} -eq 1 ]; then - CONFIG_ITEM[i]=${CONFIG_ITEM[i]}"\\"${TMP_LETTER} - idx=${idx}+1 - continue - fi ;; " ") idx=${idx}+1 @@ -176,6 +170,21 @@ parse_line() { 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 } diff --git a/lustre/scripts/lc_lvm.sh.in b/lustre/scripts/lc_lvm.sh.in index 35b7a40..64018d2 100644 --- a/lustre/scripts/lc_lvm.sh.in +++ b/lustre/scripts/lc_lvm.sh.in @@ -241,7 +241,7 @@ get_lvm_items() { && [ "${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 @@ -253,10 +253,6 @@ get_lvm_items() { 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:"\ diff --git a/lustre/scripts/lc_md.sh.in b/lustre/scripts/lc_md.sh.in index a2a2228..842b801 100644 --- a/lustre/scripts/lc_md.sh.in +++ b/lustre/scripts/lc_md.sh.in @@ -174,7 +174,7 @@ get_md_items() { [ "`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 @@ -185,9 +185,6 @@ get_md_items() { 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:"\ diff --git a/lustre/scripts/lustre_config.sh.in b/lustre/scripts/lustre_config.sh.in index 92493b2..e0d3869 100644 --- a/lustre/scripts/lustre_config.sh.in +++ b/lustre/scripts/lustre_config.sh.in @@ -523,7 +523,6 @@ construct_mkfs_cmdline() { 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}$" " @@ -536,9 +535,6 @@ construct_mkfs_cmdline() { 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 @@ -555,7 +551,6 @@ construct_mkfs_cmdline() { 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}$" " @@ -759,7 +754,7 @@ get_items() { 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 @@ -778,6 +773,8 @@ get_items() { 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:"\