diff options
| author | Joel Martin <github@martintribe.org> | 2014-05-10 15:45:36 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-05-10 15:45:36 -0500 |
| commit | 70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb (patch) | |
| tree | 88d46c8326b233c271b9884197de6266a9f45427 /bash/reader.sh | |
| parent | 3f26b8f601c96956029fe64e1aeac7b8b9f76911 (diff) | |
| download | mal-70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb.tar.gz mal-70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb.zip | |
Bash: correctly treat commas as whitespace.
Diffstat (limited to 'bash/reader.sh')
| -rw-r--r-- | bash/reader.sh | 7 |
1 files changed, 3 insertions, 4 deletions
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= |
