# Try to read ATIP infos for CD disks to estimate capacity...
MEDIA_ATIP_INFOS=$(cdrecord dev=${MEDIA_DEV} -atip 2>&1)
-if echo ${MEDIA_ATIP_INFOS} | grep "ATIP info from disk" 1> /dev/null 2>&1; then
+if echo ${MEDIA_ATIP_INFOS} | grep -q "ATIP info from disk"; then
MEDIA_SIZE=${CD_MEDIA_SIZE}
MEDIA_TYPE="CD"
echo "CD disk detected"
-elif echo ${MEDIA_ATIP_INFOS} | grep "Found DVD media but" 1> /dev/null 2>&1; then
+elif echo ${MEDIA_ATIP_INFOS} | grep -q "Found DVD media but"; then
MEDIA_SIZE=${DVD_MEDIA_SIZE}
MEDIA_TYPE="DVD"
echo "DVD disk detected"
-elif echo ${MEDIA_ATIP_INFOS} | grep "cdrecord: No disk / Wrong disk" 1> /dev/null 2>&1; then
+elif echo ${MEDIA_ATIP_INFOS} | grep -q "cdrecord: No disk / Wrong disk"; then
echo "No disk inserted, aborting"
exit 1
else
# Create an empty file of $FILES_SIZE
dd if=/dev/zero of=${TMP_FILE} bs=1024k count=${FILES_SIZE}
-if [ $? != 0 ]; then
+if [ $? -ne 0 ]; then
echo "Error while creating empty file..."
rm -f ${TMP_FILE}
exit 1
# Create an extended-2 filesystem on this file
echo y | /sbin/mke2fs -m 0 -b 2048 ${TMP_FILE}
-if [ $? != 0 ]; then
+if [ $? -ne 0 ]; then
echo "Error creating file system on empty file..."
rm -f ${TMP_FILE}
exit 1
# Mount this empty file through the loopback device.
mkdir -p ${TMP_MOUNT}
mount -o loop -t ext2 ${TMP_FILE} ${TMP_MOUNT}
-if [ $? != 0 ]; then
+if [ $? -ne 0 ]; then
echo "Error mounting empty file..."
rm -f ${TMP_FILE}
rm -rf $TMP_MOUNT
# Copy files to $TMP_MOUNT and umount it afterwards.
echo "Copying files..."
cp -a --parents ${FILES_WRITE_LIST} ${TMP_MOUNT}
-if [ $? != 0 ]; then
+if [ $? -ne 0 ]; then
echo "Error while copying files..."
umount ${TMP_MOUNT}
rm -rf ${TMP_MOUNT}
esac
# Mounting the media to verify burned capacity
-if ! grep ${MEDIA_DEV} /etc/mtab 1> /dev/null 2>&1; then
+if ! grep -q ${MEDIA_DEV} /etc/mtab; then
mount ${MEDIA_DEV} ${MEDIA_DIR} || exit 1
fi