init.sh: simplify error reporting
This commit is contained in:
parent
caa75b5fcf
commit
b6899e8537
8
init.sh
8
init.sh
|
|
@ -25,7 +25,6 @@ name="$(echo -n $name)" # normalize whitespace
|
||||||
|
|
||||||
techname="$2"
|
techname="$2"
|
||||||
if [ -z "$techname" ]; then
|
if [ -z "$techname" ]; then
|
||||||
echo "Technical name not specified; trying to generate from the visible name" >&2
|
|
||||||
techname=$(
|
techname=$(
|
||||||
echo -n $name |
|
echo -n $name |
|
||||||
LC_ALL=C tr ' ' '-' |
|
LC_ALL=C tr ' ' '-' |
|
||||||
|
|
@ -33,11 +32,12 @@ if [ -z "$techname" ]; then
|
||||||
LC_ALL=C tr '[:upper:]' '[:lower:]' |
|
LC_ALL=C tr '[:upper:]' '[:lower:]' |
|
||||||
cat
|
cat
|
||||||
)
|
)
|
||||||
|
echo "Technical name not specified; autogenerated: \"$techname\"" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n $techname | LC_ALL=C grep '[^0-9A-Za-z_-]' && { echo 'Technical name must be ASCII alphanumeric (a-z, 0-9, also _ and - are allowed); got:' $techname; exit 2; } 2>&1
|
echo -n $techname | LC_ALL=C grep '[^0-9A-Za-z_-]' && { echo 'Technical name must be ASCII alphanumeric'; exit 2; } 2>&1
|
||||||
echo -n $techname | LC_ALL=C grep -q '^[A-Za-z]' || { echo 'Technical name must start with an ASCII letter (a-z); got:' $techname; exit 2; } 2>&1
|
echo -n $techname | LC_ALL=C grep -q '^[A-Za-z]' || { echo 'Technical name must start with an ASCII letter'; exit 2; } 2>&1
|
||||||
echo -n $techname | LC_ALL=C grep -q '[A-Za-z0-9]$' || { echo 'Technical name must end with an ASCII letter or digit (a-z, 0-9); got:' $techname; exit 2; } 2>&1
|
echo -n $techname | LC_ALL=C grep -q '[A-Za-z0-9]$' || { echo 'Technical name must end with an ASCII letter or digit'; exit 2; } 2>&1
|
||||||
|
|
||||||
echo "Project name: $name"
|
echo "Project name: $name"
|
||||||
echo "Internal name: $techname"
|
echo "Internal name: $techname"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user