2

On my Gentoo system, find . -regextype help outputs

find: Unknown regular expression type ‘help’; valid types are ‘findutils-default’, ‘awk’, ‘egrep’, ‘ed’, ‘emacs’, ‘gnu-awk’, ‘grep’, ‘posix-awk’, ‘posix-basic’, ‘posix-egrep’, ‘posix-extended’, ‘posix-minimal-basic’, ‘sed’.

I always thought smart quotes (or whatever they are called) are the scourge of Microsoft software, turns out nobody's protected from that ugliness. On my other system (Cygwin), LANG is set to en_US.UTF-8, and smart quotes are also displayed. If I unset LANG or set it to en.UTF-8, output changes to regular single quotes:

# unset LANG
# find -regextype help
find: Unknown regular expression type 'help'; valid types are 'findutils-default', 'awk', 'egrep', 'ed', 'emacs', 'gnu-awk', 'grep', 'posix-awk', 'posix-basic', 'posix-eg
rep', 'posix-extended', 'posix-minimal-basic', 'sed'.

But on the Gentoo system I mentioned earlier, LANG is unset. Whatever I try to set it (and other locale env vars) to, I see smart quotes and/or a bunch of error messages about incorrect locales.

How to get back my single quotes?

2
  • Such quotes existed in typography for centuries before "Microsoft software", and long before mechanical typewriters merged them into a single tick mark to save keys. They only got that name because of incompatibilities between Windows-1252 (which had them) and ISO-8859-1 (which didn't). So if you could please keep your religion to yourself... Commented Apr 22, 2016 at 6:12
  • 3
    Thanks, I know that. As a programmer, I really hate the way they are sometimes used in software. Let them have their place in typography, but when I'm copy-pasting some code and some software auto-converts the quotes and then another guy copy-pastes my code and it doesn't work because of wrong quotes - it's just wrong. I understand it makes sense when writing a book in a Word processor, but I think it should be user's choice to enable/disable this behavior (and word processors have option to turn off auto-correction). I'm not asking people to join my religion, just how to disable them here. Commented Apr 22, 2016 at 10:55

1 Answer 1

0

This is not auto-converted by a smart-quotes system. That text is the direct output of GNU find. A some system-wide smart-quotes interpreter would only affect input coming from the keyboard … and I've never heard of one for GNU/Linux/BSD (I found this post because I was looking for how to enable it!)

Here's a hex dump of your command output:

$ find . -regextype help 2>&1 |head -c99
find: Unknown regular expression type ‘help’; valid types are 
‘findutils-default’, ‘ed’
$ find . -regextype help 2>&1 |head -c99 |hd
00000000  66 69 6e 64 3a 20 55 6e  6b 6e 6f 77 6e 20 72 65  |find: Unknown re|
00000010  67 75 6c 61 72 20 65 78  70 72 65 73 73 69 6f 6e  |gular expression|
00000020  20 74 79 70 65 20 e2 80  98 68 65 6c 70 e2 80 99  | type ...help...|
00000030  3b 20 76 61 6c 69 64 20  74 79 70 65 73 20 61 72  |; valid types ar|
00000040  65 20 e2 80 98 66 69 6e  64 75 74 69 6c 73 2d 64  |e ...findutils-d|
00000050  65 66 61 75 6c 74 e2 80  99 2c 20 e2 80 98 65 64  |efault..., ...ed|
00000060  e2 80 99                                          |...|

This makes it easier to see that the output uses the explicit left and right single quotation march characters (U+2018 and U+2019 respectively, see this Unicode code point table). In UTF-8, these are represented as e2 80 98 and e2 80 99, which is why you see three dots (which denote non-ASCII characters) on either side of help (itself 68 56 5c 70) and the other quoted words.

You can therefore convert it back with sed:

$ find . -regextype help 2>&1 |head -c99 \
  |sed "s/\xe2\x80\x98/'/g; s/\xe2\x80\x99/'/g"
find: Unknown regular expression type 'help'; valid types are 
'findutils-default', 'ed'
$ find . -regextype help 2>&1 |head -c99 \
  |sed "s/\xe2\x80\x98/'/g; s/\xe2\x80\x99/'/g" |hd
00000000  66 69 6e 64 3a 20 55 6e  6b 6e 6f 77 6e 20 72 65  |find: Unknown re|
00000010  67 75 6c 61 72 20 65 78  70 72 65 73 73 69 6f 6e  |gular expression|
00000020  20 74 79 70 65 20 27 68  65 6c 70 27 3b 20 76 61  | type 'help'; va|
00000030  6c 69 64 20 74 79 70 65  73 20 61 72 65 20 27 66  |lid types are 'f|
00000040  69 6e 64 75 74 69 6c 73  2d 64 65 66 61 75 6c 74  |indutils-default|
00000050  27 2c 20 27 65 64 27                              |', 'ed'|
2
  • Hey, thanks for the answer. Like many other programs, GNU find uses GNU gettext for l18n. I didn't imply there's some smart-quote system in play after find had printed what it wanted to print, I'm sure it is printed directly by find, but what it prints depends on the locale. Like I mentioned, on one of my systems unsetting LANG or setting it to en.UTF-8 makes the smart quotes disappear, on the other system it doesn't (if I recall correctly, it was the same version of find - the system in question no longer exists so I can't check). Commented Feb 17, 2019 at 11:29
  • I understand that I can use sed or whatever post-processor to get rid of those quotes, but what I want is to fix the issue at the source, and make find print what I want. It should be just a question of setting the right locale... Commented Feb 17, 2019 at 11:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .