Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JelF opened this issue Apr 21, 2016 · 9 comments
Open

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

JelF opened this issue Apr 21, 2016 · 9 comments
Labels

Comments

@JelF
Copy link

JelF commented Apr 21, 2016

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

)

@nijel
Copy link
Owner

nijel commented Jul 28, 2016

I somehow can not reproduce this:

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

What enca version are you using?

@nijel nijel added the question label Jul 28, 2016
@JelF
Copy link
Author

JelF commented Jul 29, 2016

@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
Copy link
Author

JelF commented Jul 29, 2016

➜  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

nijel added a commit that referenced this issue Aug 1, 2016
nijel added a commit that referenced this issue Aug 1, 2016
@nijel
Copy link
Owner

nijel commented Aug 1, 2016

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.

@JelF
Copy link
Author

JelF commented Aug 1, 2016 via email

@nijel nijel added bug and removed question labels Aug 1, 2016
@JelF
Copy link
Author

JelF commented Aug 6, 2016

sorry, no idea how to fix :(

@nijel
Copy link
Owner

nijel commented Aug 8, 2016

Can you use gdb to see process_file return value?

@JelF
Copy link
Author

JelF commented Aug 8, 2016

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

@ferdnyc
Copy link

ferdnyc commented May 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants