validate.pl revision 1
1N/A;
# The validate routine takes a single multiline string consisting of 1N/A;
# lines containing a filename plus a file test to try on it. (The 1N/A;
# file test may also be a 'cd', causing subsequent relative filenames 1N/A;
# to be interpreted relative to that directory.) After the file test 1N/A;
# you may put '|| die' to make it a fatal error if the file test fails. 1N/A;
# The default is '|| warn'. The file test may optionally have a ! prepended 1N/A;
# to test for the opposite condition. If you do a cd and then list some 1N/A;
# relative filenames, you may want to indent them slightly for readability. 1N/A;
# If you supply your own "die" or "warn" message, you can use $file to 1N/A;
# interpolate the filename. 1N/A;
# Filetests may be bunched: -rwx tests for all of -r, -w and -x. 1N/A;
# Only the first failed test of the bunch will produce a warning. 1N/A;
# The routine returns the number of warnings issued. 1N/A;
# $warnings += do validate(' 1N/A;
# /usr -d || warn "What happened to $file?\n" 1N/A if ($
test =~ s/^(!?-)(\w{
2,}\b)/$
1Z/) {
1N/A $
tmp eq 'r' && ($
mess =
"$file is not readable by uid $>.");
1N/A $
tmp eq 'w' && ($
mess =
"$file is not writable by uid $>.");
1N/A $
tmp eq 'x' && ($
mess =
"$file is not executable by uid $>.");
1N/A $
tmp eq 'o' && ($
mess =
"$file is not owned by uid $>.");
1N/A $
tmp eq 'R' && ($
mess =
"$file is not readable by you.");
1N/A $
tmp eq 'W' && ($
mess =
"$file is not writable by you.");
1N/A $
tmp eq 'X' && ($
mess =
"$file is not executable by you.");
1N/A $
tmp eq 'O' && ($
mess =
"$file is not owned by you.");
1N/A $
tmp eq 'z' && ($
mess =
"$file does not have zero size.");
1N/A $
tmp eq 's' && ($
mess =
"$file does not have non-zero size.");
1N/A $
tmp eq 'f' && ($
mess =
"$file is not a plain file.");
1N/A $
tmp eq 'd' && ($
mess =
"$file is not a directory.");
1N/A $
tmp eq 'l' && ($
mess =
"$file is not a symbolic link.");
1N/A $
tmp eq 'p' && ($
mess =
"$file is not a named pipe (FIFO).");
1N/A $
tmp eq 'S' && ($
mess =
"$file is not a socket.");
1N/A $
tmp eq 'b' && ($
mess =
"$file is not a block special file.");
1N/A $
tmp eq 'c' && ($
mess =
"$file is not a character special file.");
1N/A $
tmp eq 'u' && ($
mess =
"$file does not have the setuid bit set.");
1N/A $
tmp eq 'g' && ($
mess =
"$file does not have the setgid bit set.");
1N/A $
tmp eq 'k' && ($
mess =
"$file does not have the sticky bit set.");
1N/A $
tmp eq 'T' && ($
mess =
"$file is not a text file.");
1N/A $
tmp eq 'B' && ($
mess =
"$file is not a binary file.");