fix: correct printer device priority fallback in txt2printr.sh
-f only matches regular files, so it never matched the /dev/lp0 or /dev/usb/lp0 character device nodes, leaving dev unset and always failing. Use -e existence checks in proper if/elif priority order (lp0 > usb/lp0 > stdout), with PRINTER_DEV as an unconditional override. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>master
parent
adf5a6ec84
commit
9019cf2fa7
|
|
@ -10,21 +10,16 @@ infile="${1:-ascii-img.txt}"
|
||||||
# Posted by John Feminella, modified by community. See post 'Timeline' for change history
|
# Posted by John Feminella, modified by community. See post 'Timeline' for change history
|
||||||
# Retrieved 2026-07-14, License - CC BY-SA 4.0
|
# Retrieved 2026-07-14, License - CC BY-SA 4.0
|
||||||
|
|
||||||
if [ -f /dev/lp0 ]; then
|
if [ -n "$PRINTER_DEV" ]; then
|
||||||
dev="${PRINTER_DEV:-/dev/lp0}"
|
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
|
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
|
if [ ! -f "$infile" ]; then
|
||||||
echo "txt2printr: file not found: $infile" >&2
|
echo "txt2printr: file not found: $infile" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue