2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
46 .TH PATHCHK 1 "Feb 1, 1995"
48 pathchk \- check path names
52 \fBpathchk\fR [\fB-p\fR] \fIpath\fR...
58 The \fBpathchk\fR command will check that one or more path names are valid
59 (that is, they could be used to access or create a file without causing syntax
60 errors) and portable (that is, no filename truncation will result). More
61 extensive portability checks are provided by the \fB-p\fR option.
64 By default, \fBpathchk\fR will check each component of each \fIpath\fR operand
65 based on the underlying file system. A diagnostic will be written for each
66 \fIpath\fR operand that:
71 is longer than \fIPATH_MAX\fR bytes.
77 contains any component longer than \fINAME_MAX\fR bytes in its containing
84 contains any component in a directory that is not searchable
90 contains any character in any component that is not valid in its containing
95 The format of the diagnostic message is not specified, but will indicate the
96 error detected and the corresponding \fIpath\fR operand.
99 It will not be considered an error if one or more components of a \fIpath\fR
100 operand do not exist as long as a file matching the path name specified by the
101 missing components could be created that does not violate any of the checks
106 The following option is supported:
113 Instead of performing checks based on the underlying file system, write a
114 diagnostic for each \fIpath\fR operand that:
119 is longer than \fB_POSIX_PATH_MAX \fR bytes
125 contains any component longer than \fB_POSIX_NAME_MAX\fR bytes
131 contains any character in any component that is not in the portable filename
139 The following operand is supported:
146 A path to be checked.
151 \fBExample 1 \fRUsing the pathchk command
154 To verify that all paths in an imported data interchange archive are legitimate
155 and unambiguous on the current system:
160 example% \fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk
165 echo Investigate problems before importing files.
174 To verify that all files in the current directory hierarchy could be moved to
175 any system conforming to the X/Open specification that also supports the
176 \fBpax\fR(1) command:
181 example% \fBfind . -print | xargs pathchk -p
186 echo Portable archive cannot be created.
195 To verify that a user-supplied path names a readable file and that the
196 application can create a file extending the given path without truncation and
197 without overwriting any existing file:
202 example% \fBcase $- in
207 test -r "$path" && pathchk "$path.out" &&
208 rm "$path.out" > "$path.out"
209 if [ $? -ne 0 ]; then
210 printf "%s: %s not found or %s.out fails \e
211 creation checks.\en" $0 "$path" "$path"
212 $reset # reset the noclobber option in case a trap
213 # on EXIT depends on it
217 PROCESSING < "$path" > "$path.out"\fR
224 The following assumptions are made in this example:
229 \fBPROCESSING\fR represents the code that will be used by the application to
230 use \fB$path\fR once it is verified that \fB$path.out\fR will work as intended.
235 The state of the \fBnoclobber\fR option is unknown when this code is invoked
236 and should be set on exit to the state it was in when this code was invoked.
237 (The \fBreset\fR variable is used in this example to restore the initial
247 \fBrm "$path.out" > "$path.out"\fR
258 The \fBpathchk\fR command has already verified, at this point, that
259 \fB$path.out\fR will not be truncated.
268 With the \fBnoclobber\fR option set, the shell will verify that \fB$path.out\fR
269 does not already exist before invoking \fBrm\fR.
278 If the shell succeeded in creating \fB$path.out\fR, \fBrm\fR will remove it so
279 that the application can create the file again in the \fBPROCESSING\fR step.
288 If the \fBPROCESSING\fR step wants the file to exist already when it is
293 \fBrm "$path.out" > "$path.out"\fR
298 should be replaced with:
307 which will verify that the file did not already exist, but leave
308 \fB$path.out\fR in place for use by \fBPROCESSING\fR.
312 .SH ENVIRONMENT VARIABLES
315 See \fBenviron\fR(5) for descriptions of the following environment variables
316 that affect the execution of \fBpathchk\fR: \fBLANG\fR, \fBLC_ALL\fR,
317 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
321 The following exit values are returned:
328 All \fIpath\fR operands passed all of the checks.
343 See \fBattributes\fR(5) for descriptions of the following attributes:
351 ATTRIBUTE TYPE ATTRIBUTE VALUE
353 Interface Stability Standard
359 \fBpax\fR(1), \fBtest\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),