}
prompt_pool() {
- echo "Available pools:"
+ # note: all prompts go to stderr so stdout contains just the result
+ >&2 echo "Available pools:"
rados lspools >"$temp_file" 2>"$lspools_err"
if [ "$?" -ne 0 ] ;then
error_out "rados lspools" "$lspools_err"
fi
- sed 's/^/ /' $temp_file # list pools and indent
- printf "Which pool do you want to search for orphans? "
+ >&2 sed 's/^/ /' "$temp_file" # list pools and indent
+ >&2 printf "Which pool do you want to search for orphans? "
local mypool
read mypool
echo $mypool
error_out "ceph-diff-sorted"
fi
-found="$(wc -l < $delta_out)"
-possible="$(wc -l < $rados_out)"
-percentage=$(expr 100 \* $found / $possible)
+found=$(wc -l < "$delta_out")
+possible=$(wc -l < "$rados_out")
+percentage=0
+if [ $possible -ne 0 ] ;then
+ percentage=$(expr 100 \* $found / $possible)
+fi
echo "$found potential orphans found out of a possible $possible (${percentage}%)."
echo "The results can be found in ${delta_out}."