ref: 3c3ba05ce6286c2a4bf691a7853412bf7e9647db
parent: e836499bb7df4260880ac0deaa7710c4a65a98a3
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 22 18:08:41 EDT 2025
libc: make needsrcquote the default This removes footguns: The documentation said that quotes were done 'in the style of rc', which was taken to mean that they were quoted for rc. Since it should always be safe to add more quotes when quoted output is acceptable, we should pick the option that the docs imply and make it the default.
--- a/sys/man/2/quote
+++ b/sys/man/2/quote
@@ -121,7 +121,7 @@
.IR *doquote ,
blanks, control characters, and quotes are always quoted.
.I Needsrcquote
-is provided as a
+is provided as the default
.I doquote
function that flags any character special to
.IR rc (1).
--- a/sys/src/cmd/aux/getflags.c
+++ b/sys/src/cmd/aux/getflags.c
@@ -79,7 +79,6 @@
Rune r;
Fmt fmt;
- doquote = needsrcquote;
quotefmtinstall();
argv0 = argv[0]; /* for sysfatal */
--- a/sys/src/cmd/du.c
+++ b/sys/src/cmd/du.c
@@ -75,7 +75,6 @@
int i, scale;
char *s, *ss, *name;
- doquote = needsrcquote;
quotefmtinstall();
ARGBEGIN {--- a/sys/src/cmd/ls.c
+++ b/sys/src/cmd/ls.c
@@ -71,7 +71,6 @@
exits("usage");}ARGEND
- doquote = needsrcquote;
quotefmtinstall();
fmtinstall('M', dirmodefmt);--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -303,7 +303,6 @@
int i;
quotefmtinstall();
- doquote = needsrcquote;
fmtinstall('U', Ufmt); ARGBEGIN{--- a/sys/src/cmd/upas/Mail/mbox.c
+++ b/sys/src/cmd/upas/Mail/mbox.c
@@ -1068,7 +1068,6 @@
int i;
mbox.view = Vgroup;
- doquote = needsrcquote;
quotefmtinstall();
tmfmtinstall();
--- a/sys/src/cmd/upas/ned/nedmail.c
+++ b/sys/src/cmd/upas/ned/nedmail.c
@@ -375,7 +375,6 @@
fmtinstall('D', Dfmt);quotefmtinstall();
- doquote = needsrcquote;
getwd(homewd, sizeof homewd);
user = getlog();
if(user == nil || *user == 0)
--- a/sys/src/libc/fmt/fmtquote.c
+++ b/sys/src/libc/fmt/fmtquote.c
@@ -51,7 +51,7 @@
break;
}
- if((c <= L' ') || (c == L'\'') || (doquote!=nil && doquote(c))){+ if((c <= L' ') || (c == L'\'') || doquote(c)){ if(!q->quoted){ if(runesout){if(1+q->nrunesout+1+1 > nout) /* no room for quotes */
--- a/sys/src/libc/port/quote.c
+++ b/sys/src/libc/port/quote.c
@@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
-int (*doquote)(int);
+int (*doquote)(int) = needsrcquote;
extern int _needsquotes(char*, int*);
extern int _runeneedsquotes(Rune*, int*);
--
⑨