File: type.tests

package info (click to toggle)
bash 4.3-11%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 37,652 kB
  • ctags: 18,453
  • sloc: ansic: 99,503; sh: 6,836; yacc: 5,032; perl: 4,227; makefile: 4,197; asm: 48; awk: 23; sed: 16
file content (97 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (4)
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
set +o posix

hash -r
unalias -a

# this should echo nothing
type
# this should be a usage error
type -r ${THIS_SH}

# these should behave identically
type notthere
command -v notthere

alias m=more

unset -f func 2>/dev/null
func() { echo this is func; }

type -t func
type -t while
type -t builtin
type -t /bin/sh
type -t ${THIS_SH}
type -t mv

type func
# the following two should produce identical output
type while
type -a while
type builtin
type /bin/sh

command -v func
command -V func
command -v while
command -V while

# the following two lines should produce the same output
# post-3.0 patch makes command -v silent, as posix specifies
# first test with alias expansion off (should all fail or produce no output)
type -t m
type m
command -v m
alias -p
alias m

# then test with alias expansion on 
shopt -s expand_aliases
type m
type -t m
command -v m
alias -p
alias m

command -V m
shopt -u expand_aliases

command -v builtin
command -V builtin
command -v /bin/sh
command -V /bin/sh

unset -f func
type func
unalias m
type m

hash -r

hash -p /bin/sh sh
type -p sh

SHBASE=${THIS_SH##*/}
hash -p /tmp/$SHBASE $SHBASE
type -p $SHBASE
type $SHBASE

type -t $SHBASE

# make sure the hash table looks right
hash

# bug in versions of bash up to and including bash-3.2
f() {
        v=$'\001'
    }

type f | cat -v

${THIS_SH} type1.sub

${THIS_SH} type2.sub

${THIS_SH} type3.sub

${THIS_SH} type4.sub