From be250bae3d5d0b2bea1e7eb49b8cf194727a632d Mon Sep 17 00:00:00 2001
From: Colin P. McCabe <cmccabe@apache.org>
Date: Wed, 1 Mar 2023 13:14:17 -0800
Subject: [PATCH] nero.sh: add -m flag

---
 nero.sh |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/nero.sh b/nero.sh
index a23cab5..5cbe709 100755
--- a/nero.sh
+++ b/nero.sh
@@ -18,16 +18,19 @@ nero.sh: CD-R burning tool for MacOS.
 -d [directory]      Create a data CD using the given directory
 -k                  Skip cleanup
 -h                  Show this help message
+-m [directory]      Create a music CD using the given directory
 EOF
 }
 
 data_dir=""
 skip_cleanup=0
-while getopts "d:kh" flag; do
+music_dir=""
+while getopts "d:khm:" flag; do
     case $flag in
         d) data_dir="${OPTARG}";;
         k) skip_cleanup=1;;
         h) usage; exit 0;;
+        m) music_dir="${OPTARG}";;
         *) usage; exit 1;;
     esac
 done
@@ -35,6 +38,7 @@ shift $OPTIND
 [[ $# -ne 0 ]] || die "unknown arguments at end. -h for help."
 
 if [[ $data_dir != "" ]]; then
+    [[ $music_dir != "" ]] && die "You must specify only one of -d and -m"
     temp_dir="`mktemp -d`"
     echo "== created temporary directory $temp_dir"
     if [[ $skip_cleanup == 1 ]]; then
@@ -47,9 +51,11 @@ if [[ $data_dir != "" ]]; then
         trap remove_iso_temp EXIT
     fi
     echo "== creating ${temp_dir}/iso"
-    hdiutil makehybrid -iso -joliet -o "${temp_dir}/temp" "${data_dir}"
+    hdiutil makehybrid -iso -joliet -o "${temp_dir}/temp" "${data_dir}" || die "iso creation failed"
     echo "== burning ${temp_dir}/temp.iso"
     hdiutil burn "${temp_dir}/temp.iso"
 else
-    die "You must supply a path. -h for help."
+    [[ $music_dir == "" ]] && die "You must specify one of -d and -m"
+    echo "== burning music cd..."
+    drutil burn -audio "${music_dir}"
 fi
-- 
1.6.6.rc1.39.g9a42