--- ./src/todisc.orig	2010-09-11 16:04:07.000000000 -0500
+++ ./src/todisc	2010-09-13 19:37:54.000000000 -0500
@@ -66,7 +66,7 @@
 # check if symlink in /tmp exists and use time stamped link if so
 WORK_DIR="/tmp/todisc-work"
 
-LOG_FILE=$(readlink -f todisc.log)
+LOG_FILE=$(greadlink -f todisc.log)
 OUT_PREFIX=""
 TV_STANDARD=ntsc
 MENU_LEN=( 20 )
@@ -264,9 +264,9 @@
         test -e "$LOG_FILE" && \
         printf "%s\n%s %s\n%s\n" "$ME" "$ME" "$SEPARATOR" "$ME" >> "$LOG_FILE"
     else
-        sed "s/    */ /g;s/^ *//" <<< "$@" | fold -bs
+        gsed "s/    */ /g;s/^ *//" <<< "$@" | fold -bs
         test -e "$LOG_FILE" && \
-            printf "%s %s\n" "$ME" "$@" | sed "s/    */ /g;s/^ *//" |
+            printf "%s %s\n" "$ME" "$@" | gsed "s/    */ /g;s/^ *//" |
             fold -bs >> "$LOG_FILE"
     fi
 }
@@ -276,7 +276,7 @@
 # Returns: Exit status of the subprocess
 # To filter/prettify the subprocess output before writing it to the log file,
 # set the LOG_FILTER variable before calling this function, to e.g.
-#    LOG_FILTER="sed 's/\r/\r\n/g'"    # Replace LF with CR/LF
+#    LOG_FILTER="gsed 's/\r/\r\n/g'"    # Replace LF with CR/LF
 # ******************************************************************************
 
 # Print script name, usage notes, and optional error message, then exit.
@@ -318,14 +318,14 @@
 
 format_output()
 {
-    sed "s/    */ /g;s/^ *//"|fold -bs
+    gsed "s/    */ /g;s/^ *//"|fold -bs
 }
 
 get_font()
 {
     # If there is a filename extension, find the absolute path
     if grep -q '\...*$' <<< "$1"; then
-        readlink -f "$1"
+        greadlink -f "$1"
     # Otherwise, use the literal name
     else
         echo "$1"
@@ -345,7 +345,7 @@
 audio_length()
 {
     mplayer -noconsolecontrols -vo null -ao pcm:fast:file=/dev/null "$1" \
-    2>&1 | tr '\r' '\n' | grep ^A: | tail -1 | sed s/^.*A:// | awk '{print $1}'
+    2>&1 | tr '\r' '\n' | grep ^A: | tail -1 | gsed s/^.*A:// | awk '{print $1}'
 }
 cleanup()
 {
@@ -624,7 +624,7 @@
     yecho
     fi
     [[ $this_set = "group" ]] && echo -e "Stats for" \
-    $(readlink -f "${FILES_IN[i]}") "\n" || \
+    $(greadlink -f "${FILES_IN[i]}") "\n" || \
     echo -e "Stats for" "${FILES_IN[i]}" "\n"
     echo -e  \
     " video codec:   " \
@@ -713,7 +713,7 @@
         fi
         if test ${#FILES_TO_ENCODE[@]} -lt 12 && ! $SINGLE_SLIDESHOW; then
             for i in "${FILES_TO_ENCODE[@]}"; do
-                this_file=$(readlink -f "$i")
+                this_file=$(greadlink -f "$i")
                 test -n "$this_file" && yecho " $this_file"
             done
         fi
@@ -742,7 +742,7 @@
                 yecho
             fi
             for i in "${!FILES_TO_ENCODE[@]}"; do
-                IN=$(readlink -f "${FILES_TO_ENCODE[i]}")
+                IN=$(greadlink -f "${FILES_TO_ENCODE[i]}")
                 if $group_set; then
                     is_image=${grp_file_is_image[i]}
                     # we will replace the symlink with actual mpeg
@@ -770,7 +770,7 @@
                     fi
                     # AUDIO_FADE=false # do not fade silence FIXME ???
                 else # not an image file - outfile goes beside infile
-                    THIS_FILE=$(readlink -f "${FILES_TO_ENCODE[i]}")
+                    THIS_FILE=$(greadlink -f "${FILES_TO_ENCODE[i]}")
                     yecho "Converting $THIS_FILE"
                     echo
                     countdown 3
@@ -896,7 +896,7 @@
                 unset chapt_len_array[${#chapt_len_array[@]}-1]
                 chapter_points=$( running_total <<< ${chapt_len_array[@]} )
                 # remove trailing space
-                chapter_points=$(sed 's/[ \t]*$//' <<< $chapter_points)
+                chapter_points=$(gsed 's/[ \t]*$//' <<< $chapter_points)
                 remainder=$( bc <<< "$adjusted_length % $chapter_length" \
                 2>/dev/null)
                 (( ${nochapt[index]} )) && local group_chapters[x++]=0 ||
@@ -926,7 +926,7 @@
             for number in ${group_chapters[d]}; do
                 new_element="$new_element $(format_seconds $number),"
                 grp_chapters[d]="${grp_chapters[d]} $number"
-                grp_chapters[d]=$(sed 's/[ \t]*$//' <<< ${grp_chapters[d]})
+                grp_chapters[d]=$(gsed 's/[ \t]*$//' <<< ${grp_chapters[d]})
             done
             local array[d]=$new_element
             unset new_element
@@ -1275,7 +1275,7 @@
     </menus>
   </vmgm>
 EOF
-) |sed '/^ *$/d' >> "$DVDAUTHOR_XML"
+) |gsed '/^ *$/d' >> "$DVDAUTHOR_XML"
     get_genopts "${args[@]}"
 
     #################### test for incompatible options #######################
@@ -1577,7 +1577,7 @@
     fi
     # find out where vhook lives for ffmpeg
     ffmpeg_prefix=$(which ffmpeg)
-    ffmpeg_prefix=$(sed 's/\/bin\/ffmpeg//g' <<< "$ffmpeg_prefix")
+    ffmpeg_prefix=$(gsed 's/\/bin\/ffmpeg//g' <<< "$ffmpeg_prefix")
     imlib2_vhook="$ffmpeg_prefix/lib/vhook/imlib2.so"
 
     # check for badly compiled or otherwise unusable vhook
@@ -1650,7 +1650,7 @@
         "$outdir"/%06d.png)
         yecho "${FFMPEG_CMD[@]}" | strings
         "${FFMPEG_CMD[@]}" 2>&1 | strings >> "$LOG_FILE"
-        largest_png=$(du -s "$outdir"/*.png|sort -r |
+        largest_png=$(gdu -s "$outdir"/*.png|sort -r |
         awk 'NR>1{exit};1 {print $2}')
         mv "$largest_png" "$PREVIEW_IMG"
         yecho "Removing temporary preview files"
@@ -1744,7 +1744,7 @@
         in_files=( "${IN_FILES[@]}" )
     else
         for f in ${!grouping[@]}; do
-                in_files[f]=$(readlink -f "${grouping[f]}")
+                in_files[f]=$(greadlink -f "${grouping[f]}")
         done
     fi
     for ((i=0; i<${#in_files[@]}; i++)); do
@@ -1928,7 +1928,7 @@
     done)
     fadeout:1
 EOF
-    ) | sed '/^$/d;s/^[ \t]*//' > "$WORK_DIR/dvd-slideshow.conf"
+    ) | gsed '/^$/d;s/^[ \t]*//' > "$WORK_DIR/dvd-slideshow.conf"
 }
 
 transition_slide()
@@ -2237,7 +2237,7 @@
             if $incoming_vids || [[ $sshows -eq 1 && $inc_files -lt 1 ]]; then
                 for f in  ${!ARGS_ARRAY[@]}; do
                     FILENAMES[f]=${ARGS_ARRAY[f]}
-                    filenames[f]=$(readlink -f "${ARGS_ARRAY[f]}")
+                    filenames[f]=$(greadlink -f "${ARGS_ARRAY[f]}")
                 done
                 if $incoming_slides; then
                     SLIDESHOW=( ${SLIDESHOW[@]} : ) # is this a slideshow ?
@@ -2252,12 +2252,12 @@
                 ! $GROUPING && mk_workdir
                 unset group groupkey grp x
                 for ((i=0; i<${#ARGS_ARRAY[@]}; i++)); do
-                    grp[x++]=$(readlink -f "${ARGS_ARRAY[i]}")
+                    grp[x++]=$(greadlink -f "${ARGS_ARRAY[i]}")
                 done
                 unset x
                 [[ -z ${FILES[@]} ]] && ss_index=0 || ss_index=${#FILES[@]}
                 SLIDESHOW[ss_index]=: # is this a slideshow ?
-                FILES[ss_index]=$(readlink -f "${ARGS_ARRAY[0]}")
+                FILES[ss_index]=$(greadlink -f "${ARGS_ARRAY[0]}")
                 GROUP_IN_FILES=( "${GROUP_IN_FILES[@]}" "${grp[@]}" )
                 groupkey=${#FILES[@]}
                 GROUP[groupkey-1]=${#grp[@]}
@@ -2301,7 +2301,7 @@
             get_listargs "$@"
             unset group groupkey grp x
             for ((i=1; i<${#ARGS_ARRAY[@]}; i++)); do
-                grp[x++]=$(readlink -f "${ARGS_ARRAY[i]}")
+                grp[x++]=$(greadlink -f "${ARGS_ARRAY[i]}")
             done
             GROUP_IN_FILES=( "${GROUP_IN_FILES[@]}" "${grp[@]}" )
             ((${ARGS_ARRAY[0]})) 2>/dev/null || usage_error "Arguments to \
@@ -2339,7 +2339,7 @@
             shift
             get_listargs "$@"
             for f in  ${!ARGS_ARRAY[@]}; do
-                SLIDESHOW_MENU_THUMBS[f]=$(readlink -f "${ARGS_ARRAY[f]}")
+                SLIDESHOW_MENU_THUMBS[f]=$(greadlink -f "${ARGS_ARRAY[f]}")
             done
             ;;
         "-submenu-titles" )
@@ -2569,7 +2569,7 @@
             shift
             get_listargs "$@"
             if [[ -n ${ARGS_ARRAY[@]} ]]; then
-                SLIDESHOW_CONF=$(readlink -f "${ARGS_ARRAY[0]}")
+                SLIDESHOW_CONF=$(greadlink -f "${ARGS_ARRAY[0]}")
             fi
             USE_DVD_SLIDESHOW=:
             ;;
@@ -2666,7 +2666,7 @@
             ;;
         "-background" )
             shift
-            BACKGROUND=$(readlink -f "$1")
+            BACKGROUND=$(greadlink -f "$1")
             USERS_BACKGROUND=:
             ! [[ -e "$BACKGROUND" ]] && \
             usage_error "background \"$BACKGROUND\" does not exist"
@@ -2675,7 +2675,7 @@
             shift
             get_listargs "$@"
             for f in  ${!ARGS_ARRAY[@]}; do
-                SM_BACKGROUND[f]=$(readlink -f "${ARGS_ARRAY[f]}")
+                SM_BACKGROUND[f]=$(greadlink -f "${ARGS_ARRAY[f]}")
                 ! [[ -e ${SM_BACKGROUND[f]} ]] && usage_error \
                 "submenu background \"$SM_BACKGROUND\" does not exist"
             done
@@ -2683,7 +2683,7 @@
         "-intro" )
             shift
             DO_INTRO=:
-            INTRO_CLIP=$(readlink -f "$1")
+            INTRO_CLIP=$(greadlink -f "$1")
             ! [[ -e "$INTRO_CLIP" ]] && \
             usage_error "intro clip \"$INTRO_CLIP\" does not exist"
             ;;
@@ -2692,7 +2692,7 @@
             get_listargs "$@"
             unset f
             for f in  ${!ARGS_ARRAY[@]}; do
-                SHOWCASE_FILE[f]=$(readlink -f "${ARGS_ARRAY[f]}")
+                SHOWCASE_FILE[f]=$(greadlink -f "${ARGS_ARRAY[f]}")
             done
             SHOWCASE=:
             IMG_FMT="png"
@@ -2965,7 +2965,7 @@
             if [[ $1 = "none" ]]; then
                 BG_AUDIO="none" # for switched menus
             else
-                BG_AUDIO=$(readlink -f "$1")
+                BG_AUDIO=$(greadlink -f "$1")
                 if [[ ! -e "$BG_AUDIO" ]]; then
                     usage_error "background audio \"$BG_AUDIO\" does not exist"
                 fi
@@ -2987,7 +2987,7 @@
                         usage_error "audio file \"${ARGS_ARRAY[i]}\" not found"
                     else
                         SM_AUDIO=( "${SM_AUDIO[@]}" \
-                        "$(readlink -f "${ARGS_ARRAY[i]}")" )
+                        "$(greadlink -f "${ARGS_ARRAY[i]}")" )
                     fi
                 fi
             done
@@ -3217,13 +3217,13 @@
                 elif [[ ! -e $2 ]]; then
                     usage_error " subtitle file $2 does not exist"
                 else
-                    TOVID_OPTS+=( "$1" "$(readlink -f "$2")" )
+                    TOVID_OPTS+=( "$1" "$(greadlink -f "$2")" )
                 fi
             elif [[ $1 == "-config" ]]; then
                 if [[ ! -e $2 ]]; then
                     usage_error "config file $2 does not exist"
                 else
-                    TOVID_OPTS+=( "$1" "$(readlink -f "$2")" )
+                    TOVID_OPTS+=( "$1" "$(greadlink -f "$2")" )
                 fi
             else
                 TOVID_OPTS+=( "$1" )
@@ -3275,7 +3275,7 @@
 fi
 
 if $BURN; then
-    if [[ ! -b $(readlink -f $BURN_DEVICE) ]]; then
+    if [[ ! -b $(greadlink -f $BURN_DEVICE) ]]; then
         usage_error \
         "$BURN_DEVICE is not a valid block device file or link to a block device.
         Are you sure your burner is \"${BURN_DEVICE}\"? Specify your burner with
@@ -3387,9 +3387,9 @@
 
 # Make sure -out was provided and it is valid
 if test -n "$OUT_PREFIX"; then
-    OUT_DIR=$(readlink -f "$OUT_PREFIX")
+    OUT_DIR=$(greadlink -f "$OUT_PREFIX")
     if [[ ! -d ${OUT_DIR%/*} ]]; then
-        OUT_PATH=$(readlink -m "$OUT_PREFIX")
+        OUT_PATH=$(greadlink -m "$OUT_PREFIX")
         usage_error "The -out path ${OUT_PATH%/*}/ does not exist"
     fi
     if egrep -q '<|>|&' <<< "$OUT_DIR"; then
@@ -3530,7 +3530,7 @@
     # disallow spaces in thumb titles for text button style
     if [ "$BUTTON_STYLE" = "text" ]; then
         for ((i=0; i<${#TITLES[@]}; i++)); do
-            T=$(sed 's/^[ \t]*//;s/[ \t]*$//' <<< "${TITLES[i]}")
+            T=$(gsed 's/^[ \t]*//;s/[ \t]*$//' <<< "${TITLES[i]}")
             if grep "  " <<< "$T" >/dev/null; then
                 echo "Sorry, a maximum of one consecutive space is allowed
                 in titles for text buttons.  \"${TITLES[i]}\" has more than
@@ -3682,7 +3682,7 @@
 "todisc from the tovid suite ($TOVID_VERSION) - log for `date`" \
 "$PATTERN" >> "$LOG_FILE"
 # put the command line into the log file to aid debugging
-printf  "%s\n%s\n" todisc "${args[@]}" | sed "s/    */ /g;s/^ *//" | fold -bs >> "$LOG_FILE"
+printf  "%s\n%s\n" todisc "${args[@]}" | gsed "s/    */ /g;s/^ *//" | fold -bs >> "$LOG_FILE"
 # do some locale debugging
 echo -e "\nYou are using the following locale settings:" >> "$LOG_FILE"
 locale >>  "$LOG_FILE" 2>&1
@@ -3977,7 +3977,7 @@
 # Get absolute pathnames of all files
 if ! $VMGM_ONLY; then
     for i in "${FILES[@]}"; do
-        IN_FILES=("${IN_FILES[@]}" "$(readlink -f "$i")")
+        IN_FILES=("${IN_FILES[@]}" "$(greadlink -f "$i")")
         (( ${#FILES[@]} < 12 )) && echo "Adding: $i" || spin "Adding: ${i##*/}"
     done
 fi
@@ -4125,7 +4125,7 @@
             used ${CHAPT_ARRAY[i]}"
         fi
         # remove + sign and commas, count the number of chapters left
-        str=$(sed 's/+/ /g;s/,/ /g' <<< ${CHAPTERS[i]})
+        str=$(gsed 's/+/ /g;s/,/ /g' <<< ${CHAPTERS[i]})
         for substr in $str; do [[ $substr != 0 ]] && newchapts+=($substr); done
         CHAPTERS[i]=${#newchapts[@]}
     done
@@ -4362,7 +4362,7 @@
         #*slide_grp*.mpg are symlinks to the original images we have kept intact
         mixgroup=( "$WORK_DIR"/${TSET_NUM}-slide_grp-*.mpg )
         for g in ${!mixgroup[@]}; do
-            MIXFILES[g]=$(readlink -f "${mixgroup[g]}")
+            MIXFILES[g]=$(greadlink -f "${mixgroup[g]}")
             MIXLINKS[g]=${mixgroup[g]}
             # remove original link we can keep track of what is already encoded
             rm -f "${MIXLINKS[g]}"
@@ -4522,7 +4522,7 @@
         for ((i=0; i<${#TITLES[@]}; i++)); do
             if [[ ${#TITLES[i]} -gt 35 || \
             $(echo -e "${TITLES[i]}" |wc -l) -gt 1 ]]; then
-                TITLE[i]=$(sed 's/^  *//'<<<${TITLES[i]//\\n/ }) # no spaces or \n
+                TITLE[i]=$(gsed 's/^  *//'<<<${TITLES[i]//\\n/ }) # no spaces or \n
                 TITLE[i]=${TITLE[i]:0:35} # cut down to 35 characters maximum
                 if [ ${#TITLES[i]} -gt 35 ]; then
                     echo "  \"${TITLE[i]}...\" (${IN_FILES[i]})" # "..."
@@ -5495,7 +5495,7 @@
             $SWITCHED && MPLAYER_SEEK_VAL=${SEEK_VAL[MENU_NUM-1]}
             echo "Using mplayer to get framed images from the showcase video"
             get_framed_pics "$SHOWCASE_VIDEO" >> "$LOG_FILE" 2>&1
-            largest_png=$(du -s "$WORK_DIR"/000000*.png|sort -r |
+            largest_png=$(gdu -s "$WORK_DIR"/000000*.png|sort -r |
                                 awk 'NR>1{exit};1 {print $2}')
             mv -v "$largest_png" "$OUT"
             rm -f "$WORK_DIR"/00000*.png
@@ -5579,7 +5579,7 @@
         if [ "$SC_FRAMESTYLE" = "glass" ]; then
             MPLAYER_SEEK_VAL=${SEEK_VAL[i]}
             get_framed_pics "${IN_FILES[i]}"  >> "$LOG_FILE" 2>&1
-            largest_png=$(du -s $WORK_DIR/000*[0-9].png | sort -r |
+            largest_png=$(gdu -s $WORK_DIR/000*[0-9].png | sort -r |
                                         awk 'NR>1{exit};1 {print $2}')
             mv -f $largest_png $WORK_DIR/pics/$i/$(printf "%06d%s" 0 .$IMG_FMT)
             rm -f "$WORK_DIR"/000*[0-9].png
@@ -6698,7 +6698,7 @@
     echo ". . . Getting stats on grouped files now . . ."
     echo
     for u in ${!grouping[@]}; do
-        CUR_VID=$(readlink -f "${grouping[u]}")
+        CUR_VID=$(greadlink -f "${grouping[u]}")
         spin "Getting stats on "${CUR_VID##*/}""
         group_idvid_stats[u]=$(idvid -terse -accurate "$CUR_VID" 2>/dev/null)
         if [ -s "$CUR_VID.nav_log" ]; then
@@ -7356,7 +7356,7 @@
   </stream>
 </subpictures>
 EOF
-) |sed '/^ *$/d'  > "$SPUMUX_XML"
+) |gsed '/^ *$/d'  > "$SPUMUX_XML"
 
 if $SUB_MENU; then
     JUMP=menu
@@ -7526,7 +7526,7 @@
 echo "$POST"
             echo "      </pgc>"
             echo "      <pgc>"
-        done | sed '$d'
+        done | gsed '$d'
 fi)
     </menus>
     <titles>
@@ -7674,7 +7674,7 @@
 echo -e "</dvdauthor>"
 fi)
 EOF
-) |sed '/^ *$/d' >> "$DVDAUTHOR_XML"
+) |gsed '/^ *$/d' >> "$DVDAUTHOR_XML"
 ##############################################################################
 #                            Animenu stuff                                   #
 ##############################################################################
@@ -7859,7 +7859,7 @@
                 else
                     CUR_FILE="${IN_FILES[i]}"
                 fi
-                navlog=$(readlink -f "${CUR_FILE}").nav_log
+                navlog=$(greadlink -f "${CUR_FILE}").nav_log
                 if [[ -s $navlog ]]; then
                     NAVSEEK="--nav_seek" && NAVLOG="$navlog"
                 else
@@ -7871,8 +7871,8 @@
                 $NAVSEEK "$NAVLOG" -o "${PICS_OUT[@]}" -f \
                 $FRAME_RATE -Z ${GEO_ARRAY[C]},fast -c $t -y $SM_IMG_FMT,null)
                 echo "Running ${TCODE_CMD[@]}" |
-                sed 's/    */ /g'|sed -e "s/^ *//"|tee -a >> "$LOG_FILE"
-                #sed 's/    */ /g'|sed -e "s/^ *//"|fold -bs >> "$LOG_FILE"
+                gsed 's/    */ /g'|gsed -e "s/^ *//"|tee -a >> "$LOG_FILE"
+                #gsed 's/    */ /g'|gsed -e "s/^ *//"|fold -bs >> "$LOG_FILE"
                 echo >> "$LOG_FILE"
                 run_transcode()
                 {
@@ -8015,7 +8015,7 @@
                     for ((b=0; b<${CHAPTERS[i]}; b++)); do
                         IMGS=( "${IMGS[@]}" $(find $WORK_DIR/animenu/$b \
                         -name \*.$SM_IMG_FMT| sort 2>/dev/null | head -n $a |
-                        sed -n -e "$a p") )
+                        gsed -n -e "$a p") )
                     done
                     IM_CMD=(convert "${IMGS[@]}" -bordercolor '#6E6E6E' \
                     -border $THUMB_FRAME_SIZE miff:-)
@@ -8197,7 +8197,7 @@
                 echo -e "Running:
                 sox $WORK_DIR/menu$s.wav $WORK_DIR/menu$s-processed.wav fade t
                 $SM_FADE ${SUBMENU_AUDIOLEN[s]} $SM_FADE" |
-                sed 's/    */ /g' | format_output
+                gsed 's/    */ /g' | format_output
                 sox -q $WORK_DIR/menu$s.wav $WORK_DIR/menu$s-processed.wav \
                  fade t $SM_FADE ${SUBMENU_AUDIOLEN[s]} $SM_FADE
                 rm $WORK_DIR/menu$s.wav
@@ -8329,7 +8329,7 @@
         num_procs=0
         for p in ${!SC_PICS[@]}; do
             ((num_procs++)) # how many processes are running
-            this_pic=$(sed 's,.*/,,;s/^0*//;s/.png//' <<< "${SC_PICS[p]}")
+            this_pic=$(gsed 's,.*/,,;s/^0*//;s/.png//' <<< "${SC_PICS[p]}")
             pic="${SC_PICS[p]}"
             # if glass and either wave or rotate
             if [ "$SC_FRAMESTYLE" = "glass" ] && \
@@ -9189,10 +9189,10 @@
     for ((x=1; x<=V_TOTAL; x++)); do
         yecho "Running spumux "$WORK_DIR/submenu${x}_spumux.xml" < \
         $WORK_DIR/menu${x}.mpg > \
-        $(sed 's/\(.*\)menu/\1Menu/' <<< $WORK_DIR/menu${x}.mpg)"|fold -bs
+        $(gsed 's/\(.*\)menu/\1Menu/' <<< $WORK_DIR/menu${x}.mpg)"|fold -bs
         spumux "$WORK_DIR/submenu${x}_spumux.xml" < \
         $WORK_DIR/menu${x}.mpg > \
-        $(sed 's/\(.*\)menu/\1Menu/' <<< $BASEDIR/${TSET_NUM}-menu${x}.mpg) \
+        $(gsed 's/\(.*\)menu/\1Menu/' <<< $BASEDIR/${TSET_NUM}-menu${x}.mpg) \
         2>> "$LOG_FILE"
     done
 fi
