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

Cat/bat command does not work as expected on all files #113

Open
ashprice opened this issue Apr 7, 2022 · 17 comments
Open

Cat/bat command does not work as expected on all files #113

ashprice opened this issue Apr 7, 2022 · 17 comments

Comments

@ashprice
Copy link

ashprice commented Apr 7, 2022

I use bat as a cat alias, but this applies to both. Basically, some files cat as expected, without refreshing the screen, other files print the cat very briefly, then clear the screen and print a fresh clifm prompt.

The weird thing is that some files work as expected despite having the same file ending as files that don't. Eg. a file called shortcutsrc produces the bug, a file called aliasesrc does not. Files with some ending like .conf usually behave as expected, so I assume there is somewhere I should be looking in the documentation about this?

To Reproduce
Open clifm. cat or bat away.

Expected behavior
cat/bat should print all files as it would in a regular terminal prompt, without clearing the screen.

Desktop (please complete the following information):
Arch Linux 5.17.1-arch1-1, st, dwm, clifm-git 1.5.1.r68.gd60abd60-1 from the AUR.

Additional context
Sorry if this is explained how to adjust in the documentation and I've missed it!

@leo-arch
Copy link
Owner

leo-arch commented Apr 7, 2022

Hi @ashprice. Thanks for reporting.

When this happens, the screen is cleared (only a CliFM's prompt, no list of files), or refreshed (the list of files is reprinted)?

Does this happen only if the command is aliased?

@ashprice
Copy link
Author

ashprice commented Apr 7, 2022

The screen is refreshed (the list of files is reprinted).

I was sure it was happening before with regular cat, but I can confirm now that it is happening only with bat - whether it is aliased to cat, or called normally with bat <some-text-file>.

I would guess support for tools like this would have to be added individually?

@leo-arch
Copy link
Owner

leo-arch commented Apr 7, 2022

It's not a matter of support. This is what I think is happening: CliFM updates the screen whenever the inotify file monitoring system (kqueue on BSD and MacOS) informs that some file was modified in the current working directory. So, we have three possibilities here:

  1. The monitoring system itself (inotify/kqueue) is buggy (highly unlikely)
  2. CliFM fails to correctly understand some file system events (maybe edge cases)
  3. There is a bug in bat itself (or it somehow modifies the filesystem, maybe a temp file or something)

Whatever it may be, I need to clearly reproduce the issue to track the bug and fix it. For the time being, it's good to know it only happens with bat. What is exactly the command you're running? By default bat runs in a pager, which does not fit your description of the issue (other files print the cat very briefly, then clear the screen and print a fresh clifm prompt)

@ashprice
Copy link
Author

ashprice commented Apr 8, 2022

I am only running bat, with no arguments other than an object file:

$ type bat
bat is /usr/bin/bat
[2022-04-08T09:20:04+0100] /home/hearth:bat shortcutrc 

I don't know if bat failing would be related to the CPU spikes I am seeing from clifm (100% of one core seemingly at random if clifm is open for a while) - I have been waiting and trying to spot a pattern in usage before opening an issue on that one.

@leo-arch
Copy link
Owner

leo-arch commented Apr 8, 2022

Hi @ashprice. I'll keep an eye of the bat issue. As to the cpu spikes thing, this needs to be tracked down and fixed, for sure, but I don't think it is related to former issue. We need some kind of pattern to make these issues reproducible. Please keep me informed.

Both issues added to the bugs list.

@leo-arch
Copy link
Owner

leo-arch commented Apr 9, 2022

Made a little adjustment to the inotify system to solve a long time bug: the screen is refreshed when it shouldn't. Give it a try now: if we're lucky enough, both issues could be fixed in a single stroke.

@leo-arch
Copy link
Owner

Hi @ashprice. Could you please confirm that this issue is solved (or not)?

@ashprice
Copy link
Author

ashprice commented Apr 23, 2022

Hey,
Sorry I thought I had replied, but it seems I forgot. Unfortunately, I still see the same behaviour as before with clifm-git from the AUR.
If there's any other info that could help or testing I can do on my end, let me know!

@leo-arch
Copy link
Owner

Thanks! I'll keep trying to reproduce the issue. I'll let you know.

@ashprice
Copy link
Author

Hey @leo-arch, I've a very belated updated on this - no fix sadly, but I noted some other info that might be helpful. I hadn't been using clifm (just living in the regular terminal lately) but decided to pick it up again today, remembered this issue and thought I'd have a play.

Anyway, the update is this: many files do bat perfectly fine. Others, however, do not.

Here is a random example of a file that bat's perfectly fine, gpt_custom.cfg:

logDir = /home/hearth/gtp_logs
logAllGTPCommunication = true
logSearchInfo = true
logToStderr = false
koRule = SIMPLE
scoringRule = TERRITORY
taxRule = SEKI
multiStoneSuicideLegal = false
hasButton = false
whiteHandicapBonus = 0
friendlyPassOk = false
allowResignation = true
resignThreshold = -0.90
resignConsecTurns = 3
maxTime = 600
ponderingEnabled = true
maxTimePondering = 600
lagBuffer = 1.0
numSearchThreads = 64
searchFactorAfterOnePass = 0.50
searchFactorAfterTwoPass = 0.25
searchFactorWhenWinning = 0.40
searchFactorWhenWinningThreshold = 0.95
nnCacheSizePowerOfTwo = 23
nnMutexPoolSizePowerOfTwo = 19
numNNServerThreadsPerModel = 1
openclDeviceToUseThread0 = 1

(This is a config file for an engine for analyzing games of Go.)

An example of a file that doesn't bat is this julia script:

alpha = 1.13

n = 36000000

target_sum_frequency = (0.95 * n)

item1 = 0.06055 * n

sum_frequency = 0
num_items = 1
frequency = (0.06055 * n)

for i in 1:n
    if num_items == 1
        global sum_frequency += item1
    else
        global frequency = (item1 / (num_items ^ alpha))
        if frequency <= 1
            global frequency = 1
        end
        global sum_frequency += frequency
    end
    global num_items += 1
    if sum_frequency >= target_sum_frequency
        println("Number of items: ", num_items)
        println("Frequency: ", sum_frequency)
        break
    end
end

If the latter works fine for you, the issue is probably something specific to my setup.

@leo-arch
Copy link
Owner

leo-arch commented Jan 25, 2023

Hi @ashprice. Tried both files and no issue at all.

What's the julia script's name? Just in case.
Does this happen with cat as well?
Is the problematic file displayed as it should outside clifm?

EDIT: A few suggestions:

Try running in stealth mode: clifm -S (config files are disabled)
Disable autols: clifm --no-autols

@leo-arch
Copy link
Owner

Are you running plain bat or with some specific parameter (via either a config file or command line arguments)?

@ashprice
Copy link
Author

Sorry for the slow reply!

The script was just named temp.jl

Yes, it's fine outside of clifm.

Bat is just bat. No specific configuration at all, and no passed arguments.

clifm --no-autols works! clifm -S does not.

@leo-arch
Copy link
Owner

Great. We can (almost) be sure the issue is then caused by the screen auto-refreshing feature. I'll keep trying to reproduce this issue. Thanks for your feedback @ashprice!

@cjk
Copy link

cjk commented May 12, 2023

FWIW, bat still depends internally on some less-functionality and I once had similar display-problems until I unset my LESS env-variable.
You could give this a shot if you have LESS set to something in your environment.

@leo-arch
Copy link
Owner

Thanks for the info @cjk! I'll give this a try and let you know.

@leo-arch
Copy link
Owner

A few quick tests: I've tried setting LESS to a few less arguments (-F, -FR, -FRX), and also played a bit with the PAGER environment variable (as described by the bat Wiki) to no avail: the issue remains hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants