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

Compatibility with POSIX cat for files named "cache" #245

Closed
muendelezaji opened this issue Aug 31, 2018 · 4 comments
Closed

Compatibility with POSIX cat for files named "cache" #245

muendelezaji opened this issue Aug 31, 2018 · 4 comments
Labels
feature-request New feature or request good first issue Good for newcomers

Comments

@muendelezaji
Copy link

muendelezaji commented Aug 31, 2018

First, thanks for this very useful utility. This is not really a bug at this point since it appears to be a design choice (#82), but thought it would be nice to get clarification on this.

bat treats files named cache (and previously, init-cache) as a subcommand and fails when it's the first argument. Granted this only happens when the file appears first AND is in the current directory, so probably not a big deal. But it does mean this just misses being a drop-in replacement for cat (esp. in non-interactive scenarios) and potentially breaks POSIX compliance (only - is a special filename). I see there's also talk on adding more subcommands on #23 which would depart further from compatibility.

In following on the project goals, is there any good way around this? Perhaps by using --cache-X or other approach.

Edit: Linking to POSIX compliance issue – #134

@sharkdp
Copy link
Owner

sharkdp commented Aug 31, 2018

First, thanks for this very useful utility.

Thank you for your feedback!

bat treats files named cache (and previously, init-cache) as a subcommand and fails when it's the first argument. Granted this only happens when the file appears first AND is in the current directory, so probably not a big deal. But it does mean this just misses being a drop-in replacement for cat

You are absolutely right. I thought about it, but haven't opened a ticket.

I see there's also talk on adding more subcommands on #23 which would depart further from compatibility.

I don't think we plan on adding more subcommands at the moment.

In following on the project goals, is there any good way around this? Perhaps by using --cache-X or other approach.

--cache-X could be one option, yes. Another way to achieve this would be to have a separate utility to handle the cache generation (bat-cache). I think my favorite solution would be to check if cache is a file in the current directory and to just fall back to default behavior. Now there is only a problem if someone wants to use the bat cache subcommand in a folder with a file named cache 😄

@sharkdp sharkdp changed the title Compatibility with POSIX cat Compatibility with POSIX cat for files named "cache" Aug 31, 2018
@sharkdp sharkdp added feature-request New feature or request good first issue Good for newcomers labels Aug 31, 2018
@BK1603
Copy link
Contributor

BK1603 commented Sep 1, 2018

I would like to work on this one if no one else is working on it!

@BK1603
Copy link
Contributor

BK1603 commented Sep 3, 2018

Just a heads up, I am still working on it, I should be able to submit the PR in a day or two!

BK1603 added a commit to BK1603/bat that referenced this issue Sep 4, 2018
Now if a cache file exists in the current directory, and the use passes
no arguments to the cache command, the cache file would be displayed.
If however the user uses cache command with arguments, the cache command
would be executed as normal regardless of wether the file cache exists
in the current directory or not.
@sharkdp
Copy link
Owner

sharkdp commented Sep 5, 2018

Closed by @BK1603 (#275).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants