Skip to content

Commit fa5d035

Browse files
committed
nhc: Fix detached mode result writability test
In detached mode, we check to see if we can write to the result file before actually trying to do so, but `test -w` returns false for non-existent files, not just unwritable files. So we need to redo the logic of that test to account for both cases: (1) file exists and is writable, or (2) file does not exist but directory does and is writable. While I was at it, I also changed where the write is done to account for a third scenario: (3) everything looks like it should work but the write itself fails. Fixes #59. Thanks to @hwj0303 for spotting this!
1 parent 35b7ad6 commit fa5d035

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nhc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ function die() {
6161
fi
6262
fi
6363
if [[ -n "$NHC_DETACHED" ]]; then
64-
if [[ -w "$RESULTFILE" ]]; then
65-
echo "$RET $*" > $RESULTFILE
64+
if [[ -w "$RESULTFILE" || (! -e "$RESULTFILE" && -w "${RESULTFILE%/*}") ]] && echo "$RET $*" > $RESULTFILE ; then
65+
dbg "Wrote results file $RESULTFILE: $RET $*"
6666
else
67-
log "ERROR: $NAME: Unable to write to \"$RESULTFILE\" -- is ${RESULTFILE%/*} read-only?"
68-
syslog "ERROR: $NAME: Unable to write to \"$RESULTFILE\" -- is ${RESULTFILE%/*} read-only?"
67+
log "ERROR: $NAME: Unable to write to \"$RESULTFILE\" -- is ${RESULTFILE%/*} missing/read-only?"
68+
syslog "ERROR: $NAME: Unable to write to \"$RESULTFILE\" -- is ${RESULTFILE%/*} missing/read-only?"
6969
syslog_flush
7070
fi
7171
elif [[ "$NHC_RM" == "sge" ]]; then

0 commit comments

Comments
 (0)