File: df

package info (click to toggle)
yash 2.43-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,184 kB
  • ctags: 3,159
  • sloc: ansic: 31,766; makefile: 812; sh: 407; sed: 16
file content (163 lines) | stat: -rw-r--r-- 4,248 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# (C) 2010 magicant

# Completion script for the "df" command.
# Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0,
# Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3.

function completion/df {

	case $("${WORDS[1]}" --version 2>/dev/null) in
		(*'coreutils'*) typeset type=GNU ;;
		(*)             typeset type="$(uname 2>/dev/null)" ;;
	esac
	case $type in
		(GNU) typeset long=true ;;
		(*)   typeset long= ;;
	esac

	typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX
	POSIXOPTIONS=( #>#
	"k; print figures in kilobytes (1024-byte units)"
	"P ${long:+--portability}; print in the portable format defined by POSIX"
	) #<#

	ADDOPTIONS=()
	case $type in (GNU|*BSD|Darwin|SunOS|HP-UX)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"l ${long:+--local}; print info about local file systems only"
		) #<#
		case $type in (GNU|*BSD|Darwin|SunOS)
			ADDOPTIONS=("$ADDOPTIONS" #>#
			"h ${long:+--human-readable}; print size using K, M, etc. for 1024^n"
			) #<#
			case $type in (GNU|FreeBSD|NetBSD|Darwin|SunOS)
				ADDOPTIONS=("$ADDOPTIONS" #>#
				"a ${long:+--all}; print all file systems"
				) #<#
				case $type in (GNU|FreeBSD|NetBSD|Darwin)
					ADDOPTIONS=("$ADDOPTIONS" #>#
					"m; print figures in megabytes (1048576-byte units)"
					) #<#
					case $type in (GNU|FreeBSD|Darwin)
						ADDOPTIONS=("$ADDOPTIONS" #>#
						"H ${long:+--si}; print size using k, M, etc. for 1000^n"
						) #<#
						case $type in (GNU|FreeBSD)
							ADDOPTIONS=("$ADDOPTIONS" #>#
							"T ${long:+--print-type}; print file system types"
							) #<#
						esac
					esac
					case $type in (FreeBSD|NetBSD|Darwin)
						ADDOPTIONS=("$ADDOPTIONS" #>#
						"g; print figures in gigabytes (1073741824-byte units)"
						) #<#
						case $type in (FreeBSD|Darwin)
							ADDOPTIONS=("$ADDOPTIONS" #>#
							"b; print figures in 512-byte units"
							) #<#
						esac
					esac
				esac
			esac
			case $type in (*BSD|Darwin)
				ADDOPTIONS=("$ADDOPTIONS" #>#
				"n; allow printing cached data that may be out of date"
				) #<#
			esac
		esac
		case $type in (GNU|*BSD|Darwin|HP-UX)
			ADDOPTIONS=("$ADDOPTIONS" #>#
			"i ${long:+--inodes}; print inode information"
			) #<#
		esac
		case $type in (SunOS|HP-UX)
			ADDOPTIONS=("$ADDOPTIONS" #>#
			"b; print the size of free area in kilobytes"
			"e; print the number of files free"
			"F:; specify a file system type to print"
			"g; print all the results of the statvfs function"
			"n; print file system types"
			"o:; specify options specific to file systems"
			"v; print block counts"
			"V; print full command lines"
			) #<#
		esac
	esac
	case $type in
	(GNU)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"B: --block-size:; specify the block size unit to print figures in"
		"--total; print the grand total after the normal output"
		"--no-sync; allow printing cached data that may be out of date"
		"--sync; don't use cached data that may be out of date"
		"x: --exclude-type:; specify a file system type not to print"
		"--help"
		"--version"
		) #<#
		;;
	(FreeBSD)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"c; print the grand total"
		) #<#
		;;
	(NetBSD)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"G; print all the results of the statvfs function"
		) #<#
		;;
	(Darwin)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"T:; specify a file system type to print"
		) #<#
		;;
	(SunOS)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"Z; print file systems in all zones"
		) #<#
		;;
	(HP-UX)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"f; print the number of blocks in the free list"
		"s; don't sync the file system data on the disk"
		) #<#
		;;
	esac
	case $type in
	(GNU|*BSD)
		ADDOPTIONS=("$ADDOPTIONS" #>#
		"t: ${long:+--type:}; specify a file system type to print"
		) #<#
		;;
	(*)
		POSIXOPTIONS=("$POSIXOPTIONS" #>#
		"t; include total counts in the output"
		) #<#
		;;
	esac

	OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS")
	unset POSIXOPTIONS ADDOPTIONS

	command -f completion//parseoptions ${long:+-es}
	case $ARGOPT in
	(-)
		command -f completion//completeoptions
		;;
	(B|--block-size)
		if command -vf completion//completeblocksize >/dev/null 2>&1 ||
				. -AL completion/_blocksize; then
			command -f completion//completeblocksize
		fi
		;;
	(?|-?*)
		;;
	(*)
		complete -f
		;;
	esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 noet: