why not swap out the "echo -en" for "printf"?

Does the below patch work? It would avoid needing coreutils and 
may be portable than using echo?

(just add a REVISION bump to the port as well which I've left out here)

On Wed, 18 Feb 2026, Theo de Raadt wrote:

> Can someone write the -e and -E diff for echo like I suggest please?
> 
> Theo de Raadt <[email protected]> wrote:
> 
> > https://pubs.opengroup.org/onlinepubs/9799919799/
> > 
> > I think we should be adding the -e and -E stuff to echo
> > 
> > That still cannot use getopt, it must manually look at argv[1]
> > for - followed by a series of e, E, and n, then apply it.  If the
> > pattern isn't precisely -[eEn]* it should print it as if it
> > wasn't this special argument.
> > 
> > 
> > joshua stein <[email protected]> wrote:
> > 
> > > I was trying to use the driverless thing in CUPS to be able to add 
> > > AirPrint printers on my network but 'driverless list' would never 
> > > show any printers even with Avahi running.
> > > 
> > > Turns out the driverless binary is shelling out to ippfind and 
> > > passing a long string of args to act as a filter, and that filter 
> > > depends on echo having an -e flag to print in a format that 
> > > driverless reads back.  Since we don't have -e, it was just reading 
> > > back garbage.
> > > 
> > >     ippfind -T 0 _ipps._tcp _ipp._tcp ! --txt printer-type --and \( 
> > > --txt-pdl image/pwg-raster --or --txt-pdl application/PCLm --or --txt-pdl 
> > > image/urf --or --txt-pdl application/pdf \) -x echo -en 
> > > '\n{service_scheme}\t{service_name}\t{service_domain}\t{txt_usb_MFG}\t{txt_usb_MDL}\t{txt_product}\t{txt_ty}\t{service_name}\t{txt_pdl}\t{txt_UUID}\t{txt_rfo}\t'
> > >  \; --local -x echo -en L \;
> > > 
> > > The easiest solution seemed to be to depend on gecho from coreutils 
> > > but maybe there's a shorter path.
> > > 
> > > 


------8<--- patch-utils_driverless_c ---8<-------------------------------

"echo -en" is not portable; use printf instead

Index: utils/driverless.c
--- utils/driverless.c.orig
+++ utils/driverless.c
@@ -385,7 +385,7 @@ list_printers (int mode, int reg_type_no, int isFax)
   * for our desired output.
   */
 
-  /* ippfind -T 0 _ipps._tcp _ipp._tcp ! --txt printer-type --and \( --txt-pdl 
image/pwg-raster --or --txt-pdl application/PCLm --or --txt-pdl image/urf --or 
--txt-pdl application/pdf \) -x echo -en 
'\n{service_scheme}\t{service_name}\t{service_domain}\t{txt_usb_MFG}\t{txt_usb_MDL}\t{txt_product}\t{txt_ty}\t{service_name}\t{txt_pdl}\t{txt_UUID}\t{txt_rfo}\t'
 \; --local -x echo -en L \;*/
+  /* ippfind -T 0 _ipps._tcp _ipp._tcp ! --txt printer-type --and \( --txt-pdl 
image/pwg-raster --or --txt-pdl application/PCLm --or --txt-pdl image/urf --or 
--txt-pdl application/pdf \) -x printf 
'\n{service_scheme}\t{service_name}\t{service_domain}\t{txt_usb_MFG}\t{txt_usb_MDL}\t{txt_product}\t{txt_ty}\t{service_name}\t{txt_pdl}\t{txt_UUID}\t{txt_rfo}\t'
 \; --local -x printf L \;*/
 
   i = 0;
   ippfind_argv[i++] = "ippfind";
@@ -419,8 +419,8 @@ list_printers (int mode, int reg_type_no, int isFax)
   ippfind_argv[i++] = "application/pdf";  /* PDF */
   ippfind_argv[i++] = ")";
   ippfind_argv[i++] = "-x";
-  ippfind_argv[i++] = "echo";             /* Output the needed data fields */
-  ippfind_argv[i++] = "-en";              /* separated by tab characters */
+  ippfind_argv[i++] = "printf";             /* Output the needed data fields */
+                                            /* separated by tab characters */
   if (mode < 0) {
     if (isFax)
       ippfind_argv[i++] =
@@ -440,8 +440,7 @@ list_printers (int mode, int reg_type_no, int isFax)
   if (mode < 0) {
     ippfind_argv[i++] = "--local";        /* Rest only if local service */
     ippfind_argv[i++] = "-x";
-    ippfind_argv[i++] = "echo";           /* Output an 'L' at the end of the */
-    ippfind_argv[i++] = "-en";            /* line */
+    ippfind_argv[i++] = "printf";           /* Output an 'L' at the end of the 
line */
     ippfind_argv[i++] = "L";
     ippfind_argv[i++] = ";";
   }

Reply via email to