Você pode apenas fazer:
case $1 in (/*) pathchk -- "$1";; (*) ! : ;; esac
Isso deve ser o suficiente. E ele gravará diagnósticos para stderr e retornará a falha por componentes inacessíveis ou inacessíveis. pathchk
não é sobre os nomes existentes - é sobre < em> usáveis nomes de caminho.
The
pathchk
utility shall check that one or more pathnames are valid (that is, they could be used to access or create a file without causing syntax errors) and portable (that is, no filename truncation results). More extensive portability checks are provided by the-p
option.By default, the
pathchk
utility shall check each component of eachpathname
operand based on the underlying file system. A diagnostic shall be written for eachpathname
operand that:
Is longer than
{PATH_MAX}
bytes (see Pathname Variable Values in <limits.h>)Contains any component longer than
{NAME_MAX}
bytes in its containing directoryContains any component in a directory that is not searchable
Contains any character in any component that is not valid in its containing directory
The format of the diagnostic message is not specified, but shall indicate the error detected and the corresponding
pathname
operand.It shall not be considered an error if one or more components of a
pathname
operand do not exist as long as a file matching thepathname
specified by the missing components could be created that does not violate any of the checks specified above.