Subject: Re: a proposal for two new libc functions: shquote() and shquotev()
To: Jun-ichiro itojun Hagino <>
From: Chris G. Demetriou <>
List: tech-userlevel
Date: 03/03/2001 20:26:30
Jun-ichiro itojun Hagino <> writes:
> 	there are localized shells, which allows Japanese text input on command
> 	line for example (see freebsd ports/japanese/tcsh).

Are there /bin/sh-equivalents?

This is kind-of an interesting issue: are envionment variable values
for things like this, command names, etc., going to be in
e.g. Japanese?

how does /bin/sh cope with use of variable values and/or arguments
that are in non-ASCII strings?  Certainly, I don't see mention of
'setlocale' or multibyte chars in /bin/sh?

I think this probably says to me that either:

(1) the tools that use this are meant for C locale, or

(2) despite the additional difficulties, splitting is better than
    quoting, if you can reasonably demand that the values of the
    relevant environment variables (used for command names w/ possible
    options) be in ASCII, or

(3) you've gotta bite the bullet and do this multibyte...

If (3), splitting probably better than quote-and-hand-to-/bin/sh,
because /bin/sh isn't multibyte-char aware!


> 	if we do not use mbrtowc() over localized string, we will make mistakes
> 	because some of stateful encodings include "$" and "\" in multibyte
> 	character streams (they are part of multibyte stream, so they should 
> 	not be escaped).

With the single-quote algorithm, only single-quotes are a
problem... but I doubt that makes much difference w.r.t the argument

Chris Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.