On 6/13/17 5:00 PM, Greg Wooledge wrote: > On Tue, Jun 13, 2017 at 04:44:08PM -0400, tetsu...@scope-eye.net wrote: >> For that to work, basically the character encoding used to interpret >> the script should be (potentially) distinct from the one used to >> interact with the rest of the system. >> >> ...But that gets complicated: the shell would need to interpret the >> script in its locale of origin, but still respect the locale for other >> matters of I/O. [...] > > The main issue here is that the author's locale may not *exist* on the > user's machine. There may not be any way for bash to determine which > non-ASCII characters constitute "letters" in the author's locale.
That's quite true. If that's important to the author, he can use a shell function like this to ensure that the script can set the locale appropriately. cklocale() { local lc_ctype=$(locale | grep ^LC_CTYPE=) eval local ct=${lc_ctype#*=} case $ct in $1) return 0 ;; *) return 1 ;; esac } That works with Mac OS X, where the output of locale(1) is a series of shell assignment statements with quoted values; your mileage may vary, of course. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/