X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/d847529d086db49427251f34824b0fd4f20e8ee8..8c50cdaa68622199d80d1500be73ff040f0c0d32:/abcde diff --git a/abcde b/abcde index 41c767a..31e925a 100755 --- a/abcde +++ b/abcde @@ -156,7 +156,7 @@ checkstatus () { # Take the last line in the status file if there's multiple matches PATTERN="^$1(=.*)?$" - BLURB=$(egrep $PATTERN "$ABCDETEMPDIR/status" | tail -n 1) + BLURB=$(grep -E $PATTERN "$ABCDETEMPDIR/status" | tail -n 1) if [ -z "$BLURB" ]; then # No matches found @@ -183,7 +183,7 @@ checkwarnings () fi # Take the last line in the status file if there's multiple matches PATTERN="^$1(:.*)?$" - BLURB="$(egrep $PATTERN "$ABCDETEMPDIR/warnings" | tail -n 1)" + BLURB="$(grep -E $PATTERN "$ABCDETEMPDIR/warnings" | tail -n 1)" if [ -z "$BLURB" ]; then # negative, we did not have a negative... @@ -206,7 +206,7 @@ checkerrors () fi # Take the last line in the status file if there's multiple matches PATTERN="^$1(:.*)?$" - BLURB="$(egrep $PATTERN "$ABCDETEMPDIR/errors" | tail -n 1)" + BLURB="$(grep -E $PATTERN "$ABCDETEMPDIR/errors" | tail -n 1)" if [ -z "$BLURB" ]; then # negative, we did not have a negative... @@ -1133,11 +1133,10 @@ do_encode () *=*) ;; *) COMMENT="COMMENT=$COMMENT" ;; esac - COMMENT="--comment \"$COMMENT\"" fi - # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging - if [ ! "$DOTAG" = "y" ]; then - $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" --comment "$COMMENT" "$IN" "$OUT" + # Tag the file at encode time, as it can't be done after encoding. + if [ "$DOTAG" = "y" ]; then + RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" ${COMMENT:+--comment "$COMMENT"} "$IN" "$OUT" else $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT" fi @@ -1152,8 +1151,8 @@ do_encode () $RUN_COMMAND nice $EFFECTIVE_NICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT" ;; m4a) - # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging - if [ ! "$DOTAG" = "y" ]; then + # Tag the file at encode time, as it can't be done after encoding. + if [ "$DOTAG" = "y" ]; then $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" -o "$OUT" "$IN" else @@ -1742,7 +1741,7 @@ do_discid () vecho -n "Getting CD track info... " # In OSX, unmount the disc before a query if [ "$OSFLAVOUR" = "OSX" ]; then - disktool -u ${CDROM#/dev/} + diskutil unmount ${CDROM#/dev/} fi case "$CDROMREADERSYNTAX" in flac) @@ -1755,7 +1754,7 @@ do_discid () #vecho "Using builtin cue2discid implementation..." CUESHEET="$(metaflac $METAFLACOPTS --export-cuesheet-to=- "$CDROM")" - #TRACKS=$(echo $CUESHEET | egrep "TRACK \+[[:digit:]]\+ \+AUDIO" |wc -l) + #TRACKS=$(echo $CUESHEET | grep -E "TRACK \+[[:digit:]]\+ \+AUDIO" |wc -l) #TRACKS=0 OFFSETTIMES=( $(echo "$CUESHEET" | sed -n -e's/\ *INDEX 01\ \+//p' ) ) TRACKS=${#OFFSETTIMES[@]} @@ -1787,10 +1786,10 @@ do_discid () # log warning "something went wrong while querying the CD... Maybe a DATA CD?" # fi # -# TRACKS="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')" +# TRACKS="$(echo "$CDPARANOIAOUTPUT" | grep -E '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')" # CDPARANOIAAUDIOTRACKS="$TRACKS" # -# LEADOUT="$(echo "$CDPARANOIAOUTPUT" | egrep -o '^TOTAL[[:space:]]+([[:digit:]]+)' | get_last)" +# LEADOUT="$(echo "$CDPARANOIAOUTPUT" | grep -Eo '^TOTAL[[:space:]]+([[:digit:]]+)' | get_last)" # OFFSETS="$(echo "$CDPARANOIAOUTPUT" | sed -n -e's/^ .* \([0-9]\+\) \[.*/\1/p')" # makeids # ;; @@ -1814,7 +1813,7 @@ do_discid () fi # In OSX, remount the disc again if [ "$OSFLAVOUR" = "OSX" ]; then - disktool -m ${CDROM#/dev/} + diskutil mount ${CDROM#/dev/} fi WEHAVEACD=y DISCID=$(echo $TRACKINFO | cut -f1 -d' ') @@ -1846,7 +1845,7 @@ do_discid () if [ ! "$RET" = "0" ];then log warning "something went wrong while querying the CD... Maybe a DATA CD?" fi - TRACKS="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')" + TRACKS="$(echo "$CDPARANOIAOUTPUT" | grep -E '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')" CDPARANOIAAUDIOTRACKS="$TRACKS" else # Previous versions of abcde would store the tracks on a file, instead of the status record. @@ -1929,7 +1928,7 @@ do_discid () if [ ! -f "$ABCDETEMPDIR/discid" ]; then # Wipe and start fresh echo "abcde: $ABCDETEMPDIR/discid not found. Abcde must remove and recreate" >&2 - echo -n "this directory to continue. Continue? [y/n] (n)" >&2 + echo -n "this directory to continue. Continue [y/N]? " >&2 if [ "$INTERACTIVE" = "y" ]; then read ANSWER else @@ -2160,9 +2159,9 @@ do_localcddb () read CDDBLOCALCHOICE [ x"$CDDBLOCALCHOICE" = "x" ] && CDDBLOCALCHOICE="1" # FIXME # Introduce diff's - if echo $CDDBLOCALCHOICE | egrep "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then + if echo $CDDBLOCALCHOICE | grep -E "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then diffentries cddblocalread "$CDDBLOCALCHOICES" "$CDDBLOCALCHOICE" - elif echo $CDDBLOCALCHOICE | egrep "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then + elif echo $CDDBLOCALCHOICE | grep -E "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then # Make sure we get a valid choice CDDBLOCALCHOICENUM=$(echo $CDDBLOCALCHOICE | xargs printf %d 2>/dev/null) if [ $CDDBLOCALCHOICENUM -lt 0 ] || [ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; then @@ -2194,9 +2193,9 @@ do_localcddb () # List out disc title/author and contents do_cddbparse "${CDDBLOCALFILE}" #if [ "$CDROMREADERSYNTAX" = "flac" ] ; then - # echo -n "Embedded cuesheet entry found, use it? [y/n] (y): " >&2 + # echo -n "Embedded cuesheet entry found, use it [Y/n]? " >&2 #else - echo -n "Locally cached CDDB entry found, use it? [y/n] (y): " >&2 + echo -n "Locally cached CDDB entry found, use it [Y/n]? " >&2 #fi if [ "$INTERACTIVE" = "y" ]; then read USELOCALRESP @@ -2534,7 +2533,7 @@ do_cddbedit () echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2 read CDDBCHOICE [ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1 - if echo $CDDBCHOICE | egrep "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then + if echo $CDDBCHOICE | grep -E "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then if [ ! X"$DIFF" = "X" ]; then PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1 | xargs printf %d 2>/dev/null) PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2 | xargs printf %d 2>/dev/null) @@ -2558,7 +2557,7 @@ do_cddbedit () else echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2 fi - elif echo $CDDBCHOICE | egrep "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then + elif echo $CDDBCHOICE | grep -E "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then # Make sure we get a valid choice CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null) if [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; then @@ -2688,11 +2687,11 @@ do_cddbedit () # Some heuristics first. Look at Disc Title, and if it starts with # "Various", then we'll assume Various Artists - if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then + if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | grep -Eci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then echo "Looks like a Multi-Artist CD" >&2 VARIOUSARTISTS=y else - echo -n "Is the CD multi-artist? [y/n] (n): " >&2 + echo -n "Is the CD multi-artist [y/N]? " >&2 if [ "$INTERACTIVE" = "y" ]; then read VARIOUSARTISTS else @@ -2704,7 +2703,7 @@ do_cddbedit () # Set a default DEFAULTSTYLE=1 # Need NUMTRACKS before cddb-tool will return it: - NUMTRACKS=$(egrep '^TTITLE[0-9]+=' "$CDDBDATA" | wc -l) + NUMTRACKS=$(grep -E '^TTITLE[0-9]+=' "$CDDBDATA" | wc -l) if [ "$(grep -c "^TTITLE.*\/" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then # More than 1/2 tracks contain a "/", so guess forward DEFAULTSTYLE=1 @@ -2783,7 +2782,7 @@ do_cddbedit () # submit the modified file, if they want if [ "$NOSUBMIT" != "y" ]; then - echo -n "Do you want to submit this entry to $CDDBSUBMIT? [y/n] (n): " + echo -n "Do you want to submit this entry to $CDDBSUBMIT [y/N]? " read YESNO while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && \ [ "$YESNO" != "N" ] && [ "$YESNO" != "" ] @@ -2888,7 +2887,7 @@ do_cdread () cdda2wav | icedax) if [ "$OSFLAVOUR" = "OSX" ] ; then # Hei, we have to unmount the device before running anything like cdda2wav/icedax in OSX - disktool -u ${CDROM#/dev/} 0 + diskutil unmount ${CDROM#/dev/} 0 # Also, in OSX the cdrom device for cdda2wav/icedax changes... CDDA2WAVCDROM="IODVDServices" elif [ "$OSFLAVOUR" = "FBSD" ] ; then @@ -3131,6 +3130,7 @@ EYED3=eyeD3 VORBISCOMMENT=vorbiscomment METAFLAC=metaflac AACTAG=faac +ATOMICPARSLEY=AtomicParsley CDPARANOIA=cdparanoia CDDA2WAV=icedax @@ -3225,8 +3225,8 @@ if [ X$(uname) = "XFreeBSD" ] ; then elif [ X$(uname) = "XDarwin" ] ; then HTTPGET=curl OSFLAVOUR=OSX - # We should have disktool in OSX, but let's be sure... - NEEDDISKTOOL=y + # We should have diskutil in OSX, but let's be sure... + NEEDDISKUTIL=y CDROMREADERSYNTAX=cddafs elif [ X$(uname) = "XOpenBSD" ] ; then HTTPGET=wget @@ -3294,12 +3294,16 @@ if [ "$CDROM" = "" ] ; then CDROM=/dev/cdroms/cdrom0 elif [ -e /dev/cdrom ]; then CDROM=/dev/cdrom + elif [ -e /dev/sr0 ]; then + CDROM=/dev/sr0 elif [ -e /dev/cd0c ]; then CDROM=/dev/cd0c elif [ -e /dev/acd0c ]; then CDROM=/dev/acd0c elif [ -e /dev/disk1 ]; then CDROM=/dev/disk1 + elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part.*(disk.)$'\n' ]]; then + CDROM=/dev/${BASH_REMATCH[1]} fi fi @@ -3746,7 +3750,7 @@ case "$FLACENCODERSYNTAX" in FLACENCODEROPTS="${FLACENCODEROPTS} --replay-gain" fi # FLAC streams can be encapsulated on a Ogg transport layer - if echo "$FLACENCODEROPTS" | egrep -- "(^| )--ogg($| )" > /dev/null 2>&1 ;then + if echo "$FLACENCODEROPTS" | grep -E -- "(^| )--ogg($| )" > /dev/null 2>&1 ;then log error "FLAC on an Ogg container is not yet supported" log error "due to problem with adding comments to such files" exit 1 @@ -3908,12 +3912,12 @@ fi # Make sure a buncha things exist for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \ $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \ - $AACENCODER \ + $AACENCODER $CDDBTOOL \ ${NEEDATOMICPARSLEY+$ATOMICPARSLEY} \ ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \ ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \ ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \ - ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \ + ${NEEDDISKUTIL+diskutil} ${NEEDCDSPEED+$CDSPEED} \ ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDMP3GAIN+$MP3GAIN} \ ${NEEDMPPGAIN+$MPPGAIN} ${NEEDCUEREADER+$CUEREADER} \ ${NEEDCUE2DISCID+$CUE2DISCID} @@ -3940,7 +3944,7 @@ fi ## Now that we have metaflac, check if we need cue2discid #case $CDROMREADERSYNTAX in # flac) -# TRACKINFO=$($METAFLAC --show-tag=CDDB $CDROM | cut -d"=" -f2 | egrep "[a-f0-9]{8}") +# TRACKINFO=$($METAFLAC --show-tag=CDDB $CDROM | cut -d"=" -f2 | grep -E "[a-f0-9]{8}") # if [ "$TRACKINFO" = "" ]; then # checkexec ${NEEDCUE2DISCID+$CUE2DISCID} # fi @@ -4134,7 +4138,7 @@ if [ "$EJECTCD" = "y" ] && [ -x $(which $EJECT) ]; then cd="$(echo $CDROM | sed -e 's=.*/==;s=[a-h]$==;')" $eject $EJECTOPTS $cd elif [ X"$(uname)" = X"Darwin" ] ; then - disktool -e ${CDROM#/dev/} 0 + diskutil eject ${CDROM#/dev/} 0 else $EJECT $EJECTOPTS "$CDROM" fi @@ -4357,8 +4361,8 @@ if [ "$KEEPWAVS" = "y" ];then fi # Check if we have moved all the formats we had previously encoded, if we are not using the FORCE. if [ "$DOCLEAN" = "y" ] && [ ! "$FORCE" = "y" ]; then - ENCODED_FORMATS=$(egrep "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|') - MOVED_FORMATS=$(egrep "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut -d"-" -f3 | sort -u | tr '\n' '|') + ENCODED_FORMATS=$(grep -E "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|') + MOVED_FORMATS=$(grep -E "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut -d"-" -f3 | sort -u | tr '\n' '|') if [ "$ENCODED_FORMATS" != "$MOVED_FORMATS" ]; then log warning "The encoded formats does not match with the moved ones" log warning "Formats encoded: $( echo $ENCODED_FORMATS | tr "|" " " )"