# Copyright (C) 2016 Patrick "P. J." McDermott # # This file is part of libsh. # # libsh is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # libsh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with libsh. If not, see # . static check_args() { local params="${1}" shift 1 local p= IFS=' ' for p in ${params}; do unset IFS if ! [ ${#} -gt 0 ]; then return 1 fi case "${p}" in 'string') ;; 'int') case "${1}" in *[!0-9]*) return 1;; esac ;; esac shift 1 done unset IFS if ! [ ${#} -eq 0 ]; then return 1 fi return 0 } __alias() { local fn="${1}" local alias="${2}" local params="${*}" eval "${alias}() { ${check_args} \"\${params}\" \"\${@}\" && ${fn}; }" }