diff --git a/txt2printr.sh b/txt2printr.sh index c790fda..17f88b5 100755 --- a/txt2printr.sh +++ b/txt2printr.sh @@ -10,21 +10,16 @@ infile="${1:-ascii-img.txt}" # Posted by John Feminella, modified by community. See post 'Timeline' for change history # Retrieved 2026-07-14, License - CC BY-SA 4.0 -if [ -f /dev/lp0 ]; then - dev="${PRINTER_DEV:-/dev/lp0}" +if [ -n "$PRINTER_DEV" ]; then + dev="$PRINTER_DEV" +elif [ -e /dev/lp0 ]; then + dev=/dev/lp0 +elif [ -e /dev/usb/lp0 ]; then + dev=/dev/usb/lp0 +else + dev=/dev/stdout fi -if [ -f /dev/usb/lp0 ]; then - dev="${PRINTER_DEV:-/dev/usb/lp0}" -fi - - -if [ ( ! -f /dev/lp0 ) && ( ! -f /dev/usb/lp0 )]; then - dev="${PRINTER_DEV:-/dev/stdout}" -fi - - - if [ ! -f "$infile" ]; then echo "txt2printr: file not found: $infile" >&2 exit 1