From 01c6674bdd6b951486f021e9d7558de0d05f8e12 Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 5 Mar 2024 13:40:39 +0100 Subject: [PATCH] Changed valid printer name characters --- printer.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/printer.sh b/printer.sh index 8a0bef0..6390e4a 100644 --- a/printer.sh +++ b/printer.sh @@ -44,7 +44,7 @@ function printer_duplicate { PRINTER=${1} echo "Duplicating printer '${PRINTER}'..." - + if [ "${PRINTER}" = "" ]; then echo "No printer specified!" exit 1 @@ -106,7 +106,7 @@ function printer_rename { PRINTER=${1} NEW_NAME=${2} echo "Renaming printer '${PRINTER}' to '${NEW_NAME}'..." - + if [ "${PRINTER}" = "" ]; then echo "No printer specified!" exit 1 @@ -118,9 +118,9 @@ function printer_rename { exit 1 fi - if ! grep -qE '^[a-zA-Z0-9_]+$' <<< "${NEW_NAME}"; then + if grep -qE '[ \/'\''"?#]' <<< "${NEW_NAME}"; then echo "Invalid characters in new name '${NEW_NAME}'!" - echo "Valid characters are: A-Z a-z 0-9 _" + echo "Valid characters are anything except \" ' \\ / ? # and spaces" exit 1 fi @@ -139,7 +139,7 @@ function printer_rename { fi cp /etc/cups/printers.conf /etc/cups/printers.conf.ren_bak - + # Stop CUPS, rename, restart CUPS systemctl stop cups sed -i 's/$//' /etc/cups/printers.conf @@ -156,7 +156,7 @@ function printer_rename { function printer_clear_queue { PRINTER=${1} echo "Clearing printing queue of '${PRINTER}'..." - + if [ "${PRINTER}" = "" ]; then echo "No printer specified!" exit 1 @@ -213,4 +213,4 @@ case "$1" in usage exit 1 ;; -esac \ No newline at end of file +esac