MrLixam / minishell42

The repo for project minishell42
MIT License
2 stars 0 forks source link

Prompt with color #1

Closed lebojo closed 1 year ago

lebojo commented 1 year ago

Hello, you will have a problem with coloring prompt, because when using add_history() it will fckd up cause readling will count every color code as char and add it to length.

If you test 2 cmds, and then try to go to history WITH an actual prompt (someting in prompt) it will fckd up!

I was stuck on that problem for like 2 weeks, hope it'll help you <3

GLHF

MrLixam commented 1 year ago

hi, first of all, thanks for checking out that kind of thing :) secondly, i'm not exactly getting what error you're refering to? just for context, the prompt here is the part that isn't saved in the history, readline makes it possible to add some

MrLixam commented 1 year ago

missclick, as I was writing, prompt is just used to add in front of the user added command line could you show me how to reproduce the bug?

lebojo commented 1 year ago

For sure!

Looks my code:

Capture d’écran 2023-10-17 à 09 02 58

It's my func for create the prompt:

Capture d’écran 2023-10-17 à 09 03 25

It's similar tou yours, cause of colors.

If you try to run your minishell, with the add_history, it will bug.

To reproduce:

Then you will see the "bug"!

Of course I consider that the minishell is working ahahah.

If you want to try, on my account I've almost finished my minishell, and you can clone it to see. I just put in comment de "create_prompt" function with color (and there is one without color under, which is the one I use)

Hope it helped!

MrLixam commented 1 year ago

can't seem to reproduce at home / don't see the bug if it is present, will try to reproduce once in campus, thanks for the insight, will keep informed once I manage, or not, to recreate the bug

lebojo commented 1 year ago

It’s a bug only on mac, I don’t know why, but on linux it seems to be ok…JordanLe 17 oct. 2023 à 09:47, Liam Vincent @.***> a écrit : can't seem to reproduce at home / don't see the bug if it is present, will try to reproduce once in campus, thanks for the insight, will keep informed once I manage, or not, to recreate the bug

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

MrLixam commented 1 year ago

well, my campus runs only on linux, so should not be a problem, at least for now (ps: je viens de remarquer mais on est tout deux français il semblerait :p)