Skip to content

Commit

Permalink
fix non tty color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Jun 2, 2024
1 parent 2df5470 commit 81597ee
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ char* _(char* msg){
#endif
#include <ymp.h>
#include <stdio.h>
#include <unistd.h>


int main(int argc, char** argv, char** envp){
#ifndef no_locale
setlocale(LC_ALL, "");
Expand All @@ -30,7 +32,12 @@ int main(int argc, char** argv, char** envp){
exit(0);
}if(argc < 2){
gchar* c1 = g_strconcat(_ ("No command given."), "\n", NULL);
gchar* c2 = g_strdup_printf ("\x1b[%dm%s\x1b[;0m", 31, _ ("ymp help"));
gchar* c2;
if (isatty(fileno(stdout))){
c2 = g_strdup_printf ("\x1b[%dm%s\x1b[;0m", 31, _ ("ymp help"));
} else {
c2 = g_strdup_printf ("%s", _ ("ymp help"));
}
gchar* c3 = g_strdup_printf (_ ("Run %s for more information about usage."), c2);
gchar* msg = g_strconcat (c1, c3, NULL);
error_add (msg);
Expand Down

0 comments on commit 81597ee

Please sign in to comment.