Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/lbnl_file.nhc
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ function check_file_contents() {
# supplied arguments to the "test" command returns false.
function check_file_test() {
local OP ARG RESULT
local NEG=0
local -a FLAGS=( ) ARGS=( )

for ARG in "$@" ; do
case "$ARG" in
-[abcdefghkprstuwxOGLSN]) FLAGS[${#FLAGS[*]}]="$ARG" ;;
-!) NEG=1 ;;
-*) die 1 "$FUNCNAME: Syntax error: Invalid/unsupported operator \"$ARG\"." ; return 1 ;;
*) ARGS[${#ARGS[*]}]="$ARG" ;;
esac
Expand All @@ -169,12 +171,21 @@ function check_file_test() {
eval test $OP "$ARG"
RESULT=$?
if [[ $RESULT -ne 0 ]]; then
die 1 "$FUNCNAME: $OP $ARG returned $RESULT."
return 1
if [[ $NEG == 1 ]]; then
return 0
else
die 1 "$FUNCNAME: $OP $ARG returned $RESULT."
return 1
fi
fi
done
done
return 0
if [[ $NEG == 1 ]]; then
die 1 "$FUNCNAME: $OP $ARG returned $RESULT."
return 1
else
return 0
fi
}

# Check various aspects of the results of stat() on a file.
Expand Down