enca icon indicating copy to clipboard operation
enca copied to clipboard

Enca should probably exit 1 each time it prints 'unknown'

Open JelF opened this issue 8 years ago • 9 comments

I have some string, which encoding i want to detect (attached)

When i'm calling enca -m, result is "unknown\n", but exit code is zero (same as enca's, where response is

Macintosh Cyrillic
  LF line terminators

)

JelF avatar Apr 21 '16 04:04 JelF

I somehow can not reproduce this:

$ enca -m /tmp/123.txt
unknown
$ echo $?
1

What enca version are you using?

nijel avatar Jul 28 '16 14:07 nijel

@nijel

$ enca -v
enca 1.14

Features: +librecode-interface +iconv-interface +external-converter +language-detection +locale-alias +target-charset-auto +ENCAOPT 

As far as i see, it is not latest. I'll build it from master and try to reproduce bug sometime later

JelF avatar Jul 29 '16 16:07 JelF

➜  bin git:(master) ✗ ./enca --version
enca 1.19-dev

Features: +librecode-interface +iconv-interface +external-converter +language-detection +locale-alias +target-charset-auto +ENCAOPT 

Copyright (C) 2000-2005 David Necas (Yeti) (<[email protected]>),
              2005 Zuxy Meng (<[email protected]>).

Enca is free software; it can be copied and/or modified under the terms of
version 2 of GNU General Public License, run `enca --license' to see the full
license text.  There is NO WARRANTY; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
➜  bin git:(master) ✗ ./enca -m /tmp/123.txt 
unknown
➜  bin git:(master) ✗ echo $?
0

JelF avatar Jul 29 '16 18:07 JelF

Hmm, that's strange. On what platform is that? I've fixed some minor issues in the return codes handling, but I don't think these will fix it for you.

nijel avatar Aug 01 '16 10:08 nijel

I am currently running gentoo linux (4.3.6-ck). Pulled current master, problem persists. I'll try make PR at weekend

JelF avatar Aug 01 '16 12:08 JelF

sorry, no idea how to fix :(

JelF avatar Aug 06 '16 07:08 JelF

Can you use gdb to see process_file return value?

nijel avatar Aug 08 '16 10:08 nijel

@nijel no, i am completly not familar with gdb and other c-related stuff :(

JelF avatar Aug 08 '16 15:08 JelF

I've reproduced this. The issue appears to be, as @JelF hinted at above, that enca -m exits with the same exit value enca would, even when enca -m is outputting "unknown".

It's easiest to illustrate with an example. I'm in an en_US locale, so normally enca doesn't support my local language settings:

$ enca -m ~/Desktop/123.txt
enca: Cannot determine (or understand) your language preferences. [...etc...]
$ echo $?
1

$ echo `# When enca can't recognize the encoding at all`

$ enca -L none ~/Desktop/123.txt
Unrecognized encoding
$ echo $?
1

$ enca -L none -m ~/Desktop/123.txt
unknown
$ echo $?
1

$ echo `# When enca CAN identify the file encoding, but not the corresponding MIME type`

$ enca -L russian ~/Desktop/123.txt
Macintosh Cyrillic
  LF line terminators
$ echo $?
0

$ enca -L russian -m ~/Desktop/123.txt
unknown
$ echo $?
0

ferdnyc avatar May 02 '18 02:05 ferdnyc