From 70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 10 May 2014 15:45:36 -0500 Subject: Bash: correctly treat commas as whitespace. --- bash/reader.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'bash/reader.sh') diff --git a/bash/reader.sh b/bash/reader.sh index 585b152..ee7e505 100644 --- a/bash/reader.sh +++ b/bash/reader.sh @@ -113,7 +113,7 @@ TOKENIZE () { chunk=$(( chunk + ${chunksz} )) fi (( ${#str} == 0 )) && break - [[ "${str}" =~ ^^([][{}\(\)^@])|^(~@)|(\"(\\.|[^\\\"])*\")|^(;[^$'\n']*)|^([~\'\`])|^([^][ ~\`\'\";{}\(\)^@]+)|^[,]|^[[:space:]]+ ]] + [[ "${str}" =~ ^^([][{}\(\)^@])|^(~@)|(\"(\\.|[^\\\"])*\")|^(;[^$'\n']*)|^([~\'\`])|^([^][ ~\`\'\";{}\(\)^@\,]+)|^[,]|^[[:space:]]+ ]] match=${BASH_REMATCH[0]} str="${str:${#match}}" token="${match//$'\n'/}" @@ -123,9 +123,8 @@ TOKENIZE () { idx=$(( idx + 1 )) fi if [ -z "${match}" ]; then - echo >&2 "Tokenizing error at: ${str:0:50}" _error "Tokenizing error at: ${str:0:50}" - break + return 1 fi done } @@ -134,7 +133,7 @@ TOKENIZE () { # read in r. READ_STR () { declare -a __reader_tokens - TOKENIZE "${*}" # sets __reader_tokens + TOKENIZE "${*}" || return 1 # sets __reader_tokens #set | grep ^__reader_tokens if [ -z "${__reader_tokens[k]}" ]; then r= -- cgit v1.2.3