improved arguments validator

This commit is contained in:
Serghey Rodin 2011-12-15 00:23:23 +02:00
commit e9624651d4

View file

@ -99,7 +99,7 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|-|+|=|{|}|:|_|,|.|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|-|+|=|{|}|:|_|,|.|<|>|?|/|\|\"|'|;|%| ]" )
if [[ 0 -ne "$special_chars" ]]; then
echo "Error: $var out of range"
@ -194,7 +194,7 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:| |,|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:| |,|<|>|?|/|\|\"|'|;|%| ]" )
# Checking result
if [[ 0 -ne "$special_chars" ]]; then
@ -210,7 +210,7 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%| ]" )
needed_chars=$(echo "$val" | cut -s -f 2 -d '.')
# Checking result
@ -227,7 +227,7 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%| ]" )
# Checking result
if [[ 0 -ne "$special_chars" ]] || [ 17 -le ${#val} ]; then