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

cowsay: fix commands for zsh #5742

Merged
merged 6 commits into from
Apr 13, 2021

Conversation

nicokosi
Copy link
Collaborator

@nicokosi nicokosi commented Apr 13, 2021

Fix commands that fail with zsh due to missing escaping for the exclamation mark:

$ cowsay -f dragon "Hello!"
dquote>

$ uname -a
Darwin **** 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

$ echo $SHELL
/bin/zsh

$ cowsay -h
cow{say,think} version 3.03, (c) 1999 Tony Monroe
Usage: cowsay [-bdgpstwy] [-h] [-e eyes] [-f cowfile]
      [-l] [-n] [-T tongue] [-W wrapcolumn] [message]

@Waples
Copy link
Member

Waples commented Apr 13, 2021

Works fine for me 🤔

tested in bash and fish shells on different machines (Arch Linux, RaspberryPi Os).

unames:
Linux **** 5.11.13-arch1-1 #1 SMP PREEMPT Sat, 10 Apr 2021 20:47:14 +0000 x86_64 GNU/Linux
Linux **** 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l GNU/Linux
$  cowsay -f dragon hello!                                                                                                                                                                                 10:27:12
 ________
< hello! >
 --------
      \                    / \  //\
       \    |\___/|      /   \//  \\
            /0  0  \__  /    //  | \ \
           /     /  \/_/    //   |  \  \
           @_^_@'/   \/_   //    |   \   \
           //_^_/     \/_ //     |    \    \
        ( //) |        \///      |     \     \
      ( / /) _|_ /   )  //       |      \     _\
    ( // /) '/,_ _ _/  ( ; -.    |    _ _\.-~        .-~~~^-.
  (( / / )) ,-{        _      `-.|.-~-.           .~         `.
 (( // / ))  '/\      /                 ~-. _ .-~      .-~^-.  \
 (( /// ))      `.   {            }                   /      \  \
  (( / ))     .----~-.\        \-'                 .~         \  `. \^-.
             ///.----..>        \             _ -~             `.  ^-`  ^-_
               ///-._ _ _ _ _ _ _}^ - - - - ~                     ~-- ,.-~
                                                                  /.-~

@nicokosi
Copy link
Collaborator Author

nicokosi commented Apr 13, 2021

Works fine for me

tested in bash and fish shells on different machines (Arch Linux, RaspberryPi Os).

Thank you @Waples for testing. 👍
In fact, cowsay -f dragon "hello!" does not work with zsh.

pages.it/common/cowsay.md Outdated Show resolved Hide resolved
pages.it/common/cowsay.md Outdated Show resolved Hide resolved
pages.it/common/cowsay.md Outdated Show resolved Hide resolved
pages.ko/common/cowsay.md Outdated Show resolved Hide resolved
@nicokosi nicokosi marked this pull request as draft April 13, 2021 09:36
pages.ko/common/cowsay.md Outdated Show resolved Hide resolved
pages.ko/common/cowsay.md Outdated Show resolved Hide resolved
pages/common/cowsay.md Outdated Show resolved Hide resolved
pages/common/cowsay.md Outdated Show resolved Hide resolved
pages/common/cowsay.md Outdated Show resolved Hide resolved
Fix commands that fail with zsh due to missing escaping for the exclamation mark:

	$ cowsay -f dragon "Hello!"
	dquote>

	$ uname -a
	Darwin **** 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

	$ echo $SHELL
	/bin/zsh

	$ cowsay -h
	cow{say,think} version 3.03, (c) 1999 Tony Monroe
	Usage: cowsay [-bdgpstwy] [-h] [-e eyes] [-f cowfile]
          [-l] [-n] [-T tongue] [-W wrapcolumn] [message]
@nicokosi nicokosi force-pushed the cowsay-fix-escape branch from 7d286e8 to 559893b Compare April 13, 2021 09:40
@nicokosi nicokosi marked this pull request as ready for review April 13, 2021 09:41
@nicokosi
Copy link
Collaborator Author

nicokosi commented Apr 13, 2021

Commit 06b6a5e fixes commands for zsh replacing double-quotes with single-quotes.

@marchersimon
Copy link
Collaborator

Thank you @Waples for testing. In fact, cowsay -f dragon "hello!" does not work with zsh.

Can confirm. !" actually escapes any future exclamation marks for history expansion (!!, !$, ...), and so zsh thinks there's an unterminated quote.

@nicokosi
Copy link
Collaborator Author

(I did a git push --force in order to edit the commit message: I mentioned the zsh specificity) 😇

@nicokosi nicokosi changed the title cowsay: fix commands with exclamation mark cowsay: fix commands for zsh Apr 13, 2021
@@ -3,22 +3,22 @@
> Generate an ASCII character (by default a cow) saying or thinking something.
> More information: <https://github.com/tnalpgge/rank-amateur-cowsay>.

- Print an ASCII cow saying "Hello world!":
- Print an ASCII cow saying "Hello world\!":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Collaborator Author

@nicokosi nicokosi Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails with zsh(but I forgot to change for single quotes like other examples). 😇

pages/common/cowsay.md Outdated Show resolved Hide resolved
@navarroaxel
Copy link
Collaborator

Can we just remove the ! from the text in the examples? 😂

@marchersimon
Copy link
Collaborator

That would be the easy way 😄.

@nicokosi
Copy link
Collaborator Author

Can we just remove the ! from the text in the examples?

That's cheating. https://en.wikipedia.org/wiki/%22Hello,_World!%22_program 😉

Why not? I don't care but the current fix ('Hello world!') is the closest to the original examples.

@marchersimon
Copy link
Collaborator

How about we leave everything as is and add

> In the Z-Shell !" has to be replaced with \!"

to the command description?

But then I'm wondering if that's even worth it. ! has to be escaped almost always with the exception in bash, when it's at the end of a string. Adding that note for this might seem a bit too trivial.

@nicokosi
Copy link
Collaborator Author

How about we leave everything as is and add

In the Z-Shell !" has to be replaced with \!"

to the command description?

But then I'm wondering if that's even worth it. ! has to be escaped almost always with the exception in bash, when it's at the end of a string. Adding that note for this might seem a bit too trivial.

IMHO, it's better to choose a simple example that works for all shells (I like Hello world! but Hello world is OK for me, too). ☺️

@marchersimon
Copy link
Collaborator

I think we should keep the examples as generic as possible and since !" isn't a problem of cowsay it would fit better in a zsh related page.

Copy link
Member

@sbrl sbrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! I've got a minor suggestion below, but in terms of the exclamation merk issue I recommend that we remove the exclamation mark altogether. It can also pose an issue in Bash depending on the configuration of the shell if not quotes.

In tldr pages we aim for simplicity, and it sounds like including the exclamation mark would increase the complexity of the page.

pages/common/cowsay.md Outdated Show resolved Hide resolved
nicokosi and others added 2 commits April 13, 2021 17:57
Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
@marchersimon
Copy link
Collaborator

@nicokosi I think we should move back to double quotes too.

@bl-ue bl-ue added page edit Changes to an existing page(s). translation Translate pages from one language to another. labels Apr 13, 2021
@nicokosi
Copy link
Collaborator Author

@nicokosi I think we should move back to double quotes too.

Done in e4125a2.

Copy link
Contributor

@bl-ue bl-ue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 _______ 
< LGTM! >
 ------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


@marchersimon marchersimon merged commit 6c4068b into tldr-pages:master Apr 13, 2021
@nicokosi nicokosi deleted the cowsay-fix-escape branch April 14, 2021 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
page edit Changes to an existing page(s). translation Translate pages from one language to another.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants