PATHCHK(1) General Commands Manual PATHCHK(1)

pathchkvalidate filenames

pathchk [-Pp] path

Checks for validity and/or portability of paths:

Failed paths and components are listed in the standard error stream alongside the failed predicate.

With -p, each path is considered as if on an abstract base-line POSIX system:

Otherwise, it resides on the current system:

Additionally reject empty paths and components starting with "-"s.
Check for the POSIX system (see above).

if any path failed any check.

Check whether a directory tree can be safely transferred to any conformant system:

$ find . -exec pathchk -Pp {} +
pathchk: ./POSIX/POSIX.1-202x_d1.pdf: POSIX.1-202x_d1.pdf: too long (19 > 14)
pathchk: ./POSIX/IEEE P1003.2 Draft 11.2−September 1991.txt: IEEE P1003.2 Draft 11.2−September 1991.txt: too long (44 > 14)
pathchk: ./POSIX/IEEE P1003.2 Draft 11.2−September 1991.txt: IEEE P1003.2 Draft 11.2−September 1991.txt: non-portable characters:    − 
pathchk: ./BSD/UNIX_Users_Manual_Release_3_Jun80.pdf: UNIX_Users_Manual_Release_3_Jun80.pdf: too long (37 > 14)
pathchk: ./BSD/PWB UNIX User's Manual, Edition 1.0.pdf: PWB UNIX User's Manual, Edition 1.0.pdf: too long (39 > 14)
pathchk: ./BSD/PWB UNIX User's Manual, Edition 1.0.pdf: PWB UNIX User's Manual, Edition 1.0.pdf: non-portable characters:   ' ,  
pathchk: ./Документация по ДЕМОС 2.10.tbz2: Документация по ДЕМОС 2.10.tbz2: too long (50 > 14)
pathchk: ./Документация по ДЕМОС 2.10.tbz2: Документация по ДЕМОС 2.10.tbz2: non-portable characters: Документация по ДЕМОС
pathchk: ./fips180-2withchangenotice.pdf: fips180-2withchangenotice.pdf: too long (29 > 14)

pathconf(3)

Conforms to IEEE Std 1003.1-2008 (“POSIX.1”); --portability is an extension, originating from the GNU system.

Created in IEEE Std 1003.2-1992 (“POSIX.2”) with only -p, to, alongside sh(1) noclobber (set -C), replace the need for the proposed mktemp(1), validfnam, and similar utilities, quoting pairing pathchk with a loop over "$TMPDIR/application_abbreviation$$.suffix" as sufficient, instead.

IEEE Std 1003.1-2008 (“POSIX.1”) adds -P, noting that the -Pp needs to be used to ensure "full filename portability" across all systems, with the split being retained for compatibility.

PATH_MAX, well, isn't — it's defined to 4096 on all modern systems for compatibility, but longer paths are, usually, perfectly legal, just not necessarily usable as a syscall argument. Keep this in mind.

April 24, 2023 voreutils pre-v0.0.0-latest