mirror of
				git://git.code.sf.net/p/zsh/code
				synced 2025-10-31 06:00:54 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			63 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| #compdef mkdir gmkdir zf_mkdir
 | |
| 
 | |
| local curcontext="$curcontext" state line expl args variant 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]'
 | |
|   '(-)*: :->directories'
 | |
| )
 | |
| 
 | |
| _pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --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
 | |
| 
 | |
| case $variant in
 | |
|   gnu|freebsd*|dragonfly*)
 | |
|     args+=(
 | |
|       '(-v --verbose)'{-v,--verbose}'[print message for each created directory]'
 | |
|     )
 | |
|   ;|
 | |
|   gnu)
 | |
|     if [[ $OSTYPE == linux* ]]; then
 | |
|       args+=(
 | |
|         '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
 | |
|       )
 | |
|     fi
 | |
|     args+=(
 | |
|       '(- :)--help[display help information]'
 | |
|       '(- :)--version[display version information]'
 | |
|     )
 | |
|   ;;
 | |
|   zsh) # remove all options
 | |
|   ;;
 | |
|   *) # non-GNU: remove long options
 | |
|     args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} )
 | |
|   ;;
 | |
| esac
 | |
| 
 | |
| _arguments -C -s $args && ret=0
 | |
| 
 | |
| case "$state" in
 | |
|   directories)
 | |
|     _wanted directories expl \
 | |
|       'parent directory (alternatively specify name of directory)' \
 | |
|       _path_files -/ && ret=0
 | |
|   ;;
 | |
| esac
 | |
| 
 | |
| return ret
 |