mirror of
				git://git.code.sf.net/p/zsh/code
				synced 2025-11-04 07:21:06 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
#compdef hexdump hd
 | 
						|
 | 
						|
local -a args fmts optpar
 | 
						|
fmts=(
 | 
						|
 {--one-byte-octal,-b}'[one-byte octal display]'
 | 
						|
 {--one-byte-char,-c}'[one-byte character display]'
 | 
						|
 {--two-bytes-decimal,-d}'[two-byte decimal display]'
 | 
						|
 {--two-bytes-octal,-o}'[two-byte octal display]'
 | 
						|
 {--two-bytes-hex,-x}'[two-byte hexadecimal display]'
 | 
						|
 {--format=,-e+}'[specify format string to be used for displaying data]:format'
 | 
						|
 {--format-file=,-f+}'[specify file that contains format strings]:file:_files'
 | 
						|
)
 | 
						|
args=(
 | 
						|
 '(H -n --length)'{--length=,-n+}'[interpret only specified amount of input]:length (bytes)'
 | 
						|
 '(H -s --skip)'{--skip=,-s+}'[skip specified bytes at the beginning]:offset (bytes)'
 | 
						|
 '(H -v --no-squeezing)'{--no-squeezing,-v}'[output identical lines]'
 | 
						|
)
 | 
						|
 | 
						|
[[ $service = hexdump ]] && fmts+=( {--canonical,-C}'[canonical hex+ASCII display]' )
 | 
						|
 | 
						|
if [[ $OSTYPE = linux* ]]; then
 | 
						|
  args+=(
 | 
						|
    '(-L --color)'{-L+,--color=}'[interpret color formatting specifiers colors are enabled by default]:mode'
 | 
						|
    + H
 | 
						|
    '(- *)'{-h,--help}'[display usage information]'
 | 
						|
    '(- *)'{-V,--version}'[display version information]'
 | 
						|
  )
 | 
						|
else
 | 
						|
  # strip long options by taking every second element
 | 
						|
  print -v fmts -f '%2$s' -- "$fmts[@]"
 | 
						|
  print -v args -f '%2$s' -- "$args[@]"
 | 
						|
  optpar=( -A "-*" )
 | 
						|
fi
 | 
						|
 | 
						|
_arguments -s -S $optpar '*:file:_files' $args + '(formats)' '(H)'$^fmts
 |