Unexpected exit code using dcmftest

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
judd.storrs
Posts: 1
Joined: Thu, 2013-04-04, 06:44

Unexpected exit code using dcmftest

#1 Post by judd.storrs »

There's a minor unexpected behavior with dcmftest.

dcmftest sets its exit code to the number of non-DICOM files encountered. Presumably you would expect exit code of 0 to indicate that all files are DICOM. However, at least on POSIX systems exit codes have a max value of 255, so if you're using the exit code to count files the exit code is incorrect for more than 255 files and is zero for multiples of 256.

Code: Select all

#!/bin/bash

run_test () {
	mkdir test_exit_code.$1
	cd test_exit_code.$1

	for i in $(seq 1 $1) ; do
		touch $i
	done

	echo $(ls | wc -l) files
	dcmftest * >/dev/null
	echo dcmftest exit code: $?
	echo
}

run_test 255
run_test 256
run_test 257
run_test 511
run_test 512
run_test 513

Produces the following output:

Code: Select all

255 files
dcmftest exit code: 255

256 files
dcmftest exit code: 0

257 files
dcmftest exit code: 1

511 files
dcmftest exit code: 255

512 files
dcmftest exit code: 0

513 files
dcmftest exit code: 1


Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Unexpected exit code using dcmftest

#2 Post by Michael Onken »

Hi,

Thank you for the report! We'll fix this and let you know once it's online.

Best regards,
Michael

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest