10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-12-22 04:13:34 +01:00

Fixed set None

This commit is contained in:
Anthony Scemama 2019-01-16 18:01:07 +01:00
parent 658a9e3132
commit 6301272b72
2 changed files with 27 additions and 24 deletions

View File

@ -4,7 +4,7 @@ EZFIO_ROOT=$( cd $(dirname "${BASH_SOURCE}")/.. ; pwd -P )
function _ezfio_py()
{
python2 ${EZFIO_ROOT}/Python/ezfio.py $@
python2 ${EZFIO_ROOT}/Python/ezfio.py "$@"
}
@ -82,11 +82,11 @@ function _ezfio_unset_verbose()
function _ezfio_set_file()
{
_require_first_argument $@ || return 1
_require_first_argument "$@" || return 1
if [[ ! -d $1 ]]
if [[ ! -d "$1" ]]
then
mkdir -p $1 || return 1
mkdir -p "$1" || return 1
fi
export EZFIO_FILE=$1
_ezfio_info "Set file ${EZFIO_FILE}"
@ -104,14 +104,14 @@ function _ezfio_unset_file()
function _ezfio_has()
{
_require_ezfio_file || return 1
_require_first_argument $@ || return 1
_require_first_argument "$@" || return 1
if [[ ! -d ${EZFIO_FILE}/${1,,} ]]
if [[ ! -d "${EZFIO_FILE}/${1,,}" ]]
then
return 1
fi
if [[ -z $2 ]]
if [[ -z "$2" ]]
then
return 0
fi
@ -123,14 +123,14 @@ function _ezfio_get()
{
_require_ezfio_file || return 1
if [[ -z $1 ]]
if [[ -z "$1" ]]
then
ls ${EZFIO_FILE} && return 0 || return 1
ls "${EZFIO_FILE}" && return 0 || return 1
fi
if [[ -z $2 ]]
if [[ -z "$2" ]]
then
ls ${EZFIO_FILE}/${1,,} && return 0 || return 1
ls -- "${EZFIO_FILE}/${1,,}" && return 0 || return 1
fi
_ezfio_py get $@ && return 0 || return 1
@ -139,14 +139,14 @@ function _ezfio_get()
function _ezfio_set()
{
_require_ezfio_file || return 1
_require_first_argument $@ || return 1
_require_second_argument $@ || return 2
_require_first_argument "$@" || return 1
_require_second_argument "$@" || return 2
if [[ -z $3 ]]
then
_ezfio_py set $@ || return 1
_ezfio_py set "$@" || return 1
else
echo $3 | _ezfio_py set $1 $2 || return 1
echo "$3" | _ezfio_py set "$1" "$2" || return 1
fi
return 0
}
@ -158,22 +158,22 @@ function ezfio()
case $1 in
"has")
shift
_ezfio_has $@
_ezfio_has "$@"
;;
"set")
shift
_ezfio_set $@
_ezfio_set "$@"
;;
"get")
shift
_ezfio_get $@
_ezfio_get "$@"
;;
"set_file")
shift
_ezfio_set_file $@
_ezfio_set_file "$@"
;;
"unset_file")
@ -212,12 +212,12 @@ _Complete()
prev="${COMP_WORDS[COMP_CWORD-1]}"
prev2="${COMP_WORDS[COMP_CWORD-2]}"
if [[ -n ${EZFIO_FILE} && -d ${EZFIO_FILE} ]]
if [[ -n "${EZFIO_FILE}" && -d "${EZFIO_FILE}" ]]
then
case "${prev2}" in
set|has|get)
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE}/${prev} ; ls | sed 's/\.gz//' )" -- $cur ) )
COMPREPLY=( $(compgen -W "$(cd "${EZFIO_FILE}/${prev}" ; ls | sed 's/\.gz//' )" -- $cur ) )
return 0
;;
esac
@ -228,7 +228,7 @@ _Complete()
return 0
;;
set|has|get)
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE} ; \ls -d */ | sed 's|/||g')" -- $cur ) )
COMPREPLY=( $(compgen -W "$(cd "${EZFIO_FILE}" ; \ls -d */ | sed 's|/||g')" -- $cur ) )
return 0
;;
*)
@ -260,3 +260,4 @@ _Complete()
}
complete -F _Complete ezfio

View File

@ -63,6 +63,8 @@ def main():
except:
print "Syntax Error"
return 1
if data is None:
data = "None"
f(data)
return 0