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

The strange in the example of help test, which should be - #2673

Closed
freewind opened this issue Jan 11, 2016 · 16 comments · Fixed by #3475
Closed

The strange in the example of help test, which should be - #2673

freewind opened this issue Jan 11, 2016 · 16 comments · Fixed by #3475
Assignees
Labels
bug Something that's not working as intended
Milestone

Comments

@freewind
Copy link

When you print help test in fishshell, it will print usage and an example:

Example
       if test ‐f foo.txt
               echo foo.txt exists
       else if test ‐f bar.txt
               echo bar.txt exists
       else
               echo foo.txt and bar.txt do not exist
       end

Can you find anything strange? Perhaps not.

But if you just copy and paste it to fish, and run it, it will show two errors:

test: Missing argument at index 2
test: Missing argument at index 2

The is not the same as the normal hyphen - !!! (You can copy it and search in page)

It can be a big problem for newbies of fish like me, I copied it to my shell and spent several hours to figure out why my if test doesn't working.

(I'm afraid there are similar issues in other examples, could you do a global search on the codebase when you fix it?)

@freewind
Copy link
Author

I found it has been fixed in latest codebase. (My version is 2.1.2)

But I also found another two places using it:

  1. fish-shell/share/completions/badblocks.fish: L10, filesys‐
  2. fish-shell/share/completions/fcrontab.fish: L10, VIS‐

Not sure if they are issues, just list them here as reminders.

@faho faho closed this as completed in 8e79da3 Jan 11, 2016
@faho
Copy link
Member

faho commented Jan 11, 2016

fish-shell/share/completions/badblocks.fish: L10, filesys‐
fish-shell/share/completions/fcrontab.fish: L10, VIS‐

These two have been fixed, thanks!

My version is 2.1.2

I really suggest upgrading - 2.2.0 is quite nice!

@freewind
Copy link
Author

@faho The output of test -h also contains a lot of strange -s

 The following operators are available to examine files and directories:

       · ‐b FILE returns true if FILE is a block device.

       · ‐c FILE returns true if FILE is a character device.

       · ‐d FILE returns true if FILE is a directory.

       · ‐e FILE returns true if FILE exists.

       · ‐f FILE returns true if FILE is a regular file.

When will we have a new fish release?

@faho
Copy link
Member

faho commented Jan 13, 2016

The output of test -h also contains a lot of strange -s

That output also works for me.

When will we have a new fish release?

I don't know yet. Is there anything keeping you from going to 2.2.0?

@freewind
Copy link
Author

@faho Sorry, I forgot to mention the output of previous reply is from 2.2.0, and I feel a little surprise the - is not the normal - in the output of test -h.

And in my shell, it reports errors:

~ $ fish -v
fish, version 2.2.0
~ $ test -d /etc            // normal -
~ $ test ‐d /etc            // strange ‐ copied from `test -h`
test: Missing argument at index 2
~ $

@faho
Copy link
Member

faho commented Jan 13, 2016

And in my shell, it reports errors:

That's weird. It's of course possible that it's something wrong with the toolchain used to build the docs (some formatter programs like using fancy punctuation) - what OS is this on and did you build fish yourself or is it from someone's packages?

All I know is that I can copy from my test -h output, and test -h | od -A x -t x1z also shows me that the "-" is 0x2d, i.e. ASCII "-". The - from your test -d here is 0xe28090, which is a fancy unicode "hyphen".

@freewind
Copy link
Author

My system is OS X EI Capitan 10.11.1, and using iTerm2 2.1.4.

I install fish via brew install fish:

~ $ brew install fish
Warning: fish-2.2.0 already installed
~ $ brew info fish
fish: stable 2.2.0 (bottled), HEAD
User-friendly command-line shell for UNIX-like operating systems
http://fishshell.com
/usr/local/Cellar/fish/2.2.0 (726 files, 6.7M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/fish.rb
==> Caveats
You will need to add:
  /usr/local/bin/fish
to /etc/shells.

Then run:
  chsh -s /usr/local/bin/fish
to make fish your default shell.

If you are upgrading from an older version of fish, you should now run:
  killall fishd
to terminate the outdated fish daemon.
~ $

Do you need any information else?

@faho
Copy link
Member

faho commented Jan 14, 2016

@freewind: Okay, someone on gitter confirmed your findings.

Now we need to find out where it comes from. It's not in the source, so it should come in during conversion, and we use doxygen for that - which version of that do you have (I have 1.8.11)? Unfortunately, I can't find anything on "-" being converted to anything in the doxygen documentation - I've only found something about "--" and "---".

If you want, you can try changing the "-" in doc_src/test.txt to "-".

@faho faho reopened this Jan 14, 2016
@ghost
Copy link

ghost commented Jan 14, 2016

The problem (locale-dependent) is caused by nroff used in __fish_print_help. Escaping the hyphen \- is the most proper way to solve this problem. env LC_ALL=C nroff or nroff -Tascii can solve it right fast.

@faho
Copy link
Member

faho commented Jan 14, 2016

@jakwings: Which locale triggers that? I've got de_DE.UTF-8 and also tried en_US.UTF-8 and C, none of which fail.

@ridiculousfish ridiculousfish self-assigned this Jan 14, 2016
@ridiculousfish
Copy link
Member

I see the bad dashes in test -h. I'll investigate.

@ghost
Copy link

ghost commented Jan 14, 2016

en_US.UTF-8 on mac, using /usr/bin/nroff
No problem with the gnu nroff from MacPorts, don't know why.

I just checked /etc/man.conf, there are some useful comments:

# Useful paths - note that COL should not be defined when
# NROFF is defined as "groff -Tascii" or "groff -Tlatin1";
# not only is it superfluous, but it actually damages the output.
# For use with utf-8, NROFF should be "nroff -mandoc" without -T option.
# (Maybe - but today I need -Tlatin1 to prevent double conversion to utf8.)
#
# If you have a new troff (version 1.18.1?) and its colored output
# causes problems, add the -c option to TROFF, NROFF, JNROFF.
#
TROFF           /usr/bin/groff -Tps -mandoc -c
NROFF           /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c
JNROFF          /usr/bin/groff -Tnippon -mandocj -c
EQN             /usr/bin/eqn -Tps
NEQN            /usr/bin/eqn -Tascii
JNEQN           /usr/bin/eqn -Tnippon
TBL             /usr/bin/tbl
# COL           /usr/bin/col
REFER           /usr/bin/refer
PIC             /usr/bin/pic
VGRIND
GRAP
PAGER           /usr/bin/less -is
BROWSER         /usr/bin/less -is
HTMLPAGER       /bin/cat
CAT             /bin/cat

nroff -mandoc does help with this issue too. (Oops, no).

@ghost
Copy link

ghost commented Jan 14, 2016

Problem solved somehow: env GROFF_TMAC_PATH=/MacPorts/groff/1.22.3/tmac or nroff -M/MacPorts/groff/1.22.3/tmac. (Here nroff is /usr/bin/nroff, the MacPorts ones have been uninstalled.)

Have fun with macros?

@floam floam added the bug Something that's not working as intended label Jul 5, 2016
@floam floam added this to the next-2.x milestone Jul 5, 2016
@floam
Copy link
Member

floam commented Jul 5, 2016

There's others, this is very annoying.

@krader1961
Copy link
Contributor

I can still reproduce this. The output of test -h does not contain a single ASCII hyphen. This blog post is germane. Unfortunately the author gave up before finding a solution. Doing a google search for "nroff hyphen unicode" turns up a lot of similar documents. This mailing list message however provides a couple of possible solutions.

@krader1961 krader1961 self-assigned this Oct 19, 2016
@krader1961
Copy link
Contributor

This was fixed by the groff 1.20 release with the following comment in ChangeLog.120. This is basically the same fix documented in the mailing list message I linked to in my previous comment:

2009-01-03  Werner LEMBERG  <wl@gnu.org>

        * tmac/an-old.tmac, tmac/doc.tmac: For -Tutf8, map \-, -, ', and `
        conservatively to ASCII for the sake of easy cut and paste.

This is seen on macOS up through the latest release, Sierra, because it still ships with groff 1.19. Whereas Ubuntu 16.04 (and probably most Linux distros released in the past two years) has groff 1.22 (released 2014-11-04).

It looks like simply shipping our own tmac file to augment the man.tmac file is all that's needed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants