Package: zsh
Version: 4.3.2-22
Severity: wishlist
Tags: patch

Hi!

Was a surprised that there was no completion for mkdir. So, here's
it. There's still a problem which I have not been able to solve. I
have explained that in the source.

HTH :)

Regards,
Ramkumar.



#compdef mkdir

local curcontext="$curcontext" line state \
  args args_zsh args_cmd variant expl ret=1
typeset -a opt_args

args=(
  '(-m --mode=)'{-m,--mode=}'[set permission mode]:numeric mode'
  '(-p --parents)'{-p,--parents}'[make parent directories as needed]'
  )

args_zsh=('(-)*: :->dir')

args_cmd=(
  '(-v --verbose)'{-v,--verbose}'[print message for each created directory]'
  '(- :)--help[display help information]'
  '(- :)--version[display version information]'
  '*: :->dir'
  )

case "$OSTYPE" in
  linux*)
    args_cmd=(
      '(-Z --context=)'{-Z,--context=}'[set SELinux context]:SELinux context'
      $args_cmd)
    ;;
esac

_pick_variant -r variant gnu=gnu zsh='\(eval\)' unix --help

# It can still happen that there is a precommand command or builtin in the line.
# In such cases, the variant has to be modified suitably, after further checking
# the variant of the _command_ mkdir.

# I currently don't know of any way to find out what precommands are present on
# the line. The variant should be modified like this once a way is found out:

# if [[ $variant == zsh ]]; then
#   if [[ $precommand = *command* ]]; then
#     _mkdir_command () { command mkdir "$@" }
#     _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
#   fi
# elif [[ $precommand = *builtin* ]]; then
#   variant=zsh
# fi

if [[ $variant == zsh ]]; then
  args+=($args_zsh)
else
  args+=($args_cmd)
fi

# remove long options?
[[ $variant != gnu ]] && args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} )

_arguments -C -s $args && ret=0

case "$state" in
  dir)
    if (( $ret )) && [[ ! -prefix - ]] || \
      [[ $variant == zsh && ${#${${words[2,-1]}:#-*}} -gt 0 ]]; then
      _wanted parent-directory expl \
	'parent directory (alternatively specify name of directory)' \
	_path_files -/ || _message 'name of directory'
      ret=0
    fi
    ;;
esac

return ret
-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (101, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.16-beyond2
Locale: LANG=en_IN.UTF-8, LC_CTYPE=en_IN.UTF-8 (charmap=UTF-8)

Versions of packages zsh depends on:
ii  debconf [debconf-2.0]        1.5.6       Debian configuration management sy
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  libncurses5                  5.5-5       Shared libraries for terminal hand

Versions of packages zsh recommends:
ii  libcap1                       1:1.10-14  support for getting/setting POSIX.
ii  libpcre3                      6.7-1      Perl 5 Compatible Regular Expressi

-- no debconf information

-- 
One of the main causes of the fall of the Roman Empire
was that, lacking zero, they had no way to indicate
successful termination of their C programs.
                             -- Robert Firth

Reply via email to