Better version:

> Variant #2 (not fully compatible, but more 1337):
> 
> mvcd () {
> 
>       if [[ $1 == --help || $1 == -h ]]; then
>               mv --help
>               exit 0
>       elif [[ ${#} -lt "2" ]]; then
>               echo "not enough arguments"
>               exit 1
>       fi
> 
>       destination="${!#}"
> 
>       if [[ "${destination}" == */ && ! -e "${destination}" ]]; then
>                mkdir -p "${!destination}"
>       elif [[ "${destination}" == */ && -f "${destination}" ]]; then
>               echo "destination already exists, but is a file."
>               exit 1
>       fi
> 
>       args=( "$@" )
>       unset args[$#-1]
>       set -- "${ar...@]}"
> 
>       for path in "${ar...@]}"; do
>             test "${path:0:1}" == - && MV_OPTS+="$path " && continue
>             mv $MV_OPTS "${path}" "${destination}"
>       done
> 
>       if [[ -d "${destination}" ]]; then
>               builtin cd "${destination}"
>       fi
> 
> }


Reply via email to