10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-11-19 04:22:25 +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() 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() function _ezfio_set_file()
{ {
_require_first_argument $@ || return 1 _require_first_argument "$@" || return 1
if [[ ! -d $1 ]] if [[ ! -d "$1" ]]
then then
mkdir -p $1 || return 1 mkdir -p "$1" || return 1
fi fi
export EZFIO_FILE=$1 export EZFIO_FILE=$1
_ezfio_info "Set file ${EZFIO_FILE}" _ezfio_info "Set file ${EZFIO_FILE}"
@ -103,15 +103,15 @@ function _ezfio_unset_file()
function _ezfio_has() function _ezfio_has()
{ {
_require_ezfio_file || return 1 _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 then
return 1 return 1
fi fi
if [[ -z $2 ]] if [[ -z "$2" ]]
then then
return 0 return 0
fi fi
@ -123,14 +123,14 @@ function _ezfio_get()
{ {
_require_ezfio_file || return 1 _require_ezfio_file || return 1
if [[ -z $1 ]] if [[ -z "$1" ]]
then then
ls ${EZFIO_FILE} && return 0 || return 1 ls "${EZFIO_FILE}" && return 0 || return 1
fi fi
if [[ -z $2 ]] if [[ -z "$2" ]]
then then
ls ${EZFIO_FILE}/${1,,} && return 0 || return 1 ls -- "${EZFIO_FILE}/${1,,}" && return 0 || return 1
fi fi
_ezfio_py get $@ && return 0 || return 1 _ezfio_py get $@ && return 0 || return 1
@ -138,15 +138,15 @@ function _ezfio_get()
function _ezfio_set() function _ezfio_set()
{ {
_require_ezfio_file || return 1 _require_ezfio_file || return 1
_require_first_argument $@ || return 1 _require_first_argument "$@" || return 1
_require_second_argument $@ || return 2 _require_second_argument "$@" || return 2
if [[ -z $3 ]] if [[ -z $3 ]]
then then
_ezfio_py set $@ || return 1 _ezfio_py set "$@" || return 1
else else
echo $3 | _ezfio_py set $1 $2 || return 1 echo "$3" | _ezfio_py set "$1" "$2" || return 1
fi fi
return 0 return 0
} }
@ -158,22 +158,22 @@ function ezfio()
case $1 in case $1 in
"has") "has")
shift shift
_ezfio_has $@ _ezfio_has "$@"
;; ;;
"set") "set")
shift shift
_ezfio_set $@ _ezfio_set "$@"
;; ;;
"get") "get")
shift shift
_ezfio_get $@ _ezfio_get "$@"
;; ;;
"set_file") "set_file")
shift shift
_ezfio_set_file $@ _ezfio_set_file "$@"
;; ;;
"unset_file") "unset_file")
@ -212,12 +212,12 @@ _Complete()
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
prev2="${COMP_WORDS[COMP_CWORD-2]}" prev2="${COMP_WORDS[COMP_CWORD-2]}"
if [[ -n ${EZFIO_FILE} && -d ${EZFIO_FILE} ]] if [[ -n "${EZFIO_FILE}" && -d "${EZFIO_FILE}" ]]
then then
case "${prev2}" in case "${prev2}" in
set|has|get) 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 return 0
;; ;;
esac esac
@ -228,7 +228,7 @@ _Complete()
return 0 return 0
;; ;;
set|has|get) 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 return 0
;; ;;
*) *)
@ -260,3 +260,4 @@ _Complete()
} }
complete -F _Complete ezfio complete -F _Complete ezfio

View File

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