1pathchk(1)                       User Commands                      pathchk(1)
2
3
4

NAME

6       pathchk - check path names
7

SYNOPSIS

9       pathchk [-p] path...
10
11

DESCRIPTION

13       The  pathchk  command  will check that one or more path names are valid
14       (that is, they could be used to access or create a file without causing
15       syntax  errors)  and  portable  (that  is,  no filename truncation will
16       result). More extensive portability  checks  are  provided  by  the  -p
17       option.
18
19
20       By  default,  pathchk  will  check  each component of each path operand
21       based on the underlying file system. A diagnostic will be  written  for
22       each path operand that:
23
24           o      is longer than PATH_MAX bytes.
25
26           o      contains  any  component  longer  than NAME_MAX bytes in its
27                  containing directory
28
29           o      contains any component in a directory that is not searchable
30
31           o      contains any character in any component that is not valid in
32                  its containing directory.
33
34
35       The  format  of the diagnostic message is not specified, but will indi‐
36       cate the error detected and the corresponding path operand.
37
38
39       It will not be considered an error if one or more components of a  path
40       operand do not exist as long as a file matching the path name specified
41       by the missing components could be created that does not violate any of
42       the checks specified above.
43

OPTIONS

45       The following option is supported:
46
47       -p    Instead of performing checks based on the underlying file system,
48             write a diagnostic for each path operand that:
49
50                 o      is longer than _POSIX_PATH_MAX  bytes
51
52                 o      contains any  component  longer  than  _POSIX_NAME_MAX
53                        bytes
54
55                 o      contains any character in any component that is not in
56                        the portable filename character set.
57
58

OPERANDS

60       The following operand is supported:
61
62       path    A path to be checked.
63
64

USAGE

66       See largefile(5) for the description of the behavior  of  pathchk  when
67       encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
68

EXAMPLES

70       Example 1 Using the pathchk command
71
72
73       To  verify  that  all paths in an imported data interchange archive are
74       legitimate and unambiguous on the current system:
75
76
77         example% pax -f archive | sed -e '/ == .*/s///' | xargs pathchk
78         if [ $? -eq 0 ]
79         then
80                 pax -r -f archive
81         else
82              echo Investigate problems before importing files.
83              exit 1
84         fi
85
86
87
88
89       To verify that all files in the current directory  hierarchy  could  be
90       moved  to  any  system conforming to the X/Open specification that also
91       supports the pax(1) command:
92
93
94         example% find . -print | xargs pathchk -p
95         if [ $? −eq 0 ]
96         then
97                 pax -w -f archive .
98         else
99              echo Portable archive cannot be created.
100              exit 1
101         fi
102
103
104
105
106       To verify that a user-supplied path names a readable file and that  the
107       application  can create a file extending the given path without trunca‐
108       tion and without overwriting any existing file:
109
110
111         example% case $- in
112              *C*)    reset="";;
113              *)      reset="set +C"
114                   set -C;;
115         esac
116         test -r "$path" && pathchk "$path.out" &&
117              rm "$path.out" > "$path.out"
118         if [ $? -ne 0 ]; then
119              printf "%s: %s not found or %s.out fails \
120         creation checks.\n" $0 "$path" "$path"
121              $reset    # reset the noclobber option in case a trap
122                   # on EXIT depends on it
123              exit 1
124         fi
125         $reset
126         PROCESSING < "$path" > "$path.out"
127
128
129
130
131       The following assumptions are made in this example:
132
133
134           1.     PROCESSING represents the code that  will  be  used  by  the
135                  application  to use $path once it is verified that $path.out
136                  will work as intended.
137
138           2.     The state of the noclobber option is unknown when this  code
139                  is  invoked and should be set on exit to the state it was in
140                  when this code was invoked. (The reset variable is  used  in
141                  this example to restore the initial state.)
142
143           3.     Note the usage of:
144
145                    rm "$path.out" > "$path.out"
146
147
148
149                 Tah.e pathchk command has already verified, at this point, that
150                 $path.out will not be truncated.
151
152
153           b.    With the noclobber option set, the  shell  will  verify  that
154                 $path.out does not already exist before invoking rm.
155
156
157           c.    If  the shell succeeded in creating $path.out, rm will remove
158                 it so that the application can create the file again  in  the
159                 PROCESSING step.
160
161
162           d.    If  the  PROCESSING step wants the file to exist already when
163                 it is invoked, the:
164
165                   rm "$path.out" > "$path.out"
166
167
168                 should be replaced with:
169
170                   > "$path.out"
171
172
173                 which will verify that the file did not  already  exist,  but
174                 leave $path.out in place for use by PROCESSING.
175
176

ENVIRONMENT VARIABLES

178       See  environ(5) for descriptions of the following environment variables
179       that affect the execution of pathchk: LANG, LC_ALL,  LC_CTYPE,  LC_MES‐
180       SAGES, and NLSPATH.
181

EXIT STATUS

183       The following exit values are returned:
184
185       0     All path operands passed all of the checks.
186
187
188       >0    An error occurred.
189
190

ATTRIBUTES

192       See attributes(5) for descriptions of the following attributes:
193
194
195
196
197       ┌─────────────────────────────┬─────────────────────────────┐
198       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
199       ├─────────────────────────────┼─────────────────────────────┤
200       │Availability                 │SUNWcsu                      │
201       ├─────────────────────────────┼─────────────────────────────┤
202       │Interface Stability          │Standard                     │
203       └─────────────────────────────┴─────────────────────────────┘
204

SEE ALSO

206       pax(1), test(1), attributes(5), environ(5), largefile(5), standards(5)
207
208
209
210SunOS 5.11                        1 Feb 1995                        pathchk(1)
Impressum