Commit 06080dd8 authored by Vitaly Lipatov's avatar Vitaly Lipatov

implement correct has_space() with tests

parent a8fe0722
...@@ -416,27 +416,22 @@ check_option() ...@@ -416,27 +416,22 @@ check_option()
return 0 return 0
} }
has_space()
{
[ -n "$2" ]
}
check_filenames() check_filenames()
{ {
local opt local opt
for opt in "$@" ; do for opt in "$@" ; do
# files can be with full path or have extension via . # files can be with full path or have extension via .
if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then
has_space $opt && warning "There are space(s) in filename '$opt', it is not supported. Skipped" && continue has_space "$opt" && warning "There are space(s) in filename '$opt', it is not supported. Skipped" && continue
pkg_files="$pkg_files $opt" pkg_files="$pkg_files $opt"
elif [ -d "$opt" ] ; then elif [ -d "$opt" ] ; then
has_space $opt && warning "There are space(s) in directory path '$opt', it is not supported. Skipped" && continue has_space "$opt" && warning "There are space(s) in directory path '$opt', it is not supported. Skipped" && continue
pkg_dirs="$pkg_dirs $opt" pkg_dirs="$pkg_dirs $opt"
elif echo "$opt" | grep -q "^[fhtps]*://" ; then elif echo "$opt" | grep -q "^[fhtps]*://" ; then
has_space $opt && warning "There are space(s) in URL '$opt', it is not supported. Skipped" && continue has_space "$opt" && warning "There are space(s) in URL '$opt', it is not supported. Skipped" && continue
pkg_urls="$pkg_urls $opt" pkg_urls="$pkg_urls $opt"
else else
has_space $opt && warning "There are space(s) in package name '$opt', it is not supported. Skipped" && continue has_space "$opt" && warning "There are space(s) in package name '$opt', it is not supported. Skipped" && continue
pkg_names="$pkg_names $opt" pkg_names="$pkg_names $opt"
fi fi
quoted_args="$quoted_args \"$opt\"" quoted_args="$quoted_args \"$opt\""
......
...@@ -626,3 +626,8 @@ get_pkg_name_delimiter() ...@@ -626,3 +626,8 @@ get_pkg_name_delimiter()
[ "$pkgtype" = "deb" ] && echo "_" && return [ "$pkgtype" = "deb" ] && echo "_" && return
echo "-" echo "-"
} }
has_space()
{
[ "$1" != "${1/ //}" ]
}
#!/bin/sh
has_space()
{
[ "$1" != "${1/ //}" ]
}
notok()
{
echo "notok test for '$*'"
has_space "$@" && echo "FAILED: space(s) detected"
}
ok()
{
echo "ok test for '$*'"
has_space "$@" || echo "FAILED: space(s) not detected"
}
notok "list"
ok "l i s t"
ok " l i s t "
ok " l "
ok " "
ok " "
notok ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment