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

cli: adding -. as short option for --hidden #1680

Closed
wants to merge 1 commit into from
Closed

cli: adding -. as short option for --hidden #1680

wants to merge 1 commit into from

Conversation

marcospb19
Copy link
Contributor

There was no short option for --hidden, I assume because -H is already taken by --with-filename from the original grep, and -h should always be --help.

The fact is, a lot of times when searching recursively in a directory, --hidden is needed to show files that start with an . (dot).

So doesn't it make sense to use a dot for the short flag?
rg -. PATTERN.

The only software I'm aware that uses -. is feh, however there seems to be no semantic relation with the dot itself, in contrast with ripgrep's.

@marcospb19
Copy link
Contributor Author

marcospb19 commented Sep 10, 2020

Hey, thanks for the great software, I'll understand if think that this flag is weird, it was also weird for me at first glance, so no hard feelings if you just decline it 😃 .

Also, I'm not sure if -. is portable.

@BurntSushi
Copy link
Owner

I like the cleverness of this, but I'm not sure how I feel about it. It pushes my weirdness budget, personally. I am potentially in favor of having a short flag for --hidden, although personally, I tend to use -uu instead. However, this does have the side effect of also ignoring gitignore files, which I suppose may be undesirable. But usually if I want to search hidden files, I'm probably wanting to search things in gitignore too.

As far as portable, -. wouldn't have any technical issues with being portable. With that said, using a leading . to indicate that a file is hidden is a Unix convention, and I don't know how Windows users would feel about it. (On Windows, a file being hidden is I think an actual attribute of the file's metadata.)

@okdana What are your thoughts on this?

@okdana
Copy link
Contributor

okdana commented Sep 11, 2020

I think -a is the closest thing to a standard for this, but obv that's taken. -. isn't a portability issue for rg itself (as long as you continue to use an argument-processing library that supports it), but it's possible that some external software like wrapper scripts and completion functions might not handle it well? I'm pretty sure zsh will, don't know about bash, fish, or anything Windows-related. . isn't special to any shell, though, afaik, so it does have that going for it.

I don't know. There's definitely a logic to it, but it's weird. And it sets a precedent.

@marcospb19
Copy link
Contributor Author

@BurntSushi and @okdana, thanks for the responses!

Is it possible that some external software like wrapper scripts and completion functions might not handle it well? I'm pretty sure zsh will, don't know about bash, fish, or anything Windows-related.

I assume that everything will work with zsh, bash and fish, I also tried searching for feh issues with the -. flag in the whole git history and issues/PRs sections, and I found nothing, but again, I know nothing about the Windows side of it 😞 .


As far as portable, -. wouldn't have any technical issues with being portable. With that said, using a leading . to indicate that a file is hidden is a Unix convention, and I don't know how Windows users would feel about it.

I personally think that offering a short flag as an extra option of usage will always be better than not offering a short flag option at all, if unix users can use it and enjoy it, that's a great thing.

It would be even better if someone could figure out a better option that could satisfy all the user base, however I'm out of ideas (I would suggest something with clap's short options aliases, but... this feature does not exist yet, weird).

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

While I'm still a little unsure, I decided to accept this. I like the connection between -. and hidden files, even though it is a bit Unixy.

@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label May 30, 2021
BurntSushi pushed a commit that referenced this pull request May 30, 2021
This is somewhat non-standard, but it seems nice on the surface: short
flag names are in short supply, --hidden is probably somewhat common and
-. has an obvious connection with how hidden files are named on Unix.

Closes #1680
BurntSushi pushed a commit that referenced this pull request May 31, 2021
This is somewhat non-standard, but it seems nice on the surface: short
flag names are in short supply, --hidden is probably somewhat common and
-. has an obvious connection with how hidden files are named on Unix.

Closes #1680
BurntSushi pushed a commit that referenced this pull request Jun 1, 2021
This is somewhat non-standard, but it seems nice on the surface: short
flag names are in short supply, --hidden is probably somewhat common and
-. has an obvious connection with how hidden files are named on Unix.

Closes #1680
@BurntSushi BurntSushi closed this in 4566882 Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants