chubin / cheat.sheets

cheat.sh cheat sheets repository
MIT License
598 stars 209 forks source link

Say: whitespace sensitive argument fix #119

Closed mcint closed 4 years ago

ghost commented 4 years ago

Nice. What does the ? do with say? I'm not familiar with say, but it seems to be like espeak. The question-mark is a special character in Shell-land, so wouldn't it be interpreted in some unwanted way? Could it be typo?

chubin commented 4 years ago

I've googled a little bit, and it looks like you are right @terminalforlife and there is no point of removing space here, except that one, that in this form it is (by chance) not getting interpreted by shell, and so it works properly, and that's why this illusion appears that the space is important for say itself (and it is not).

say accepts option ?, and it means "list the voices". If ? is not escaped, and there are single-letter files in the current directory, the ? is expanded, and it does not work properly. If in the directory would be some file called started with-v, e.g. -victory- the no-space variant would not work either.

So I think the best option would be to add the space back and explicitly escape the ? mark:

say -v '?'

What do you think?

ghost commented 4 years ago

That would be my approach, too. A lot of my terminal programs used to have ? as a possible help/usage argument (for old-schoolers), so I'd have assumed users would go with the escape as well. I'm surprised say is using a q-mark like that.

mcint commented 4 years ago

Good call, thanks. I appreciate not having to remember the special case behavior. I'll push a replacement quoted (or escaped) commit.