Skip to content

Commit

Permalink
fix: make install colors not always shown (#2179)
Browse files Browse the repository at this point in the history
In my terminals (konsole, kmscon, kmscon+tmux), colors won't show
without -e in
`echo -e "\033[0;32m blabla \033[0m"`.

The -e option enables interpretation of backslash escapes in the string,
which
allows the color code `\033[0;32m` to work. With -e it should be more
widely
 supported across different platforms and shell environments.

```
$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.

    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.

    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

    `echo' interprets the following backslash-escaped characters:
      \a        alert (bell)
      \b        backspace
      \c        suppress further output
      \e        escape character
      \E        escape character
      \f        form feed
      \n        new line
      \r        carriage return
      \t        horizontal tab
      \v        vertical tab
      \\        backslash
      \0nnn     the character whose ASCII code is NNN (octal).  NNN can be
                0 to 3 octal digits
```

An alternative is to directly input the escape character, or to use
printf: `printf "\033[0;32mHello\033[0m\n"`.

@leohhhh does it still work on your machine with `echo -e`? (what
terminal are you using btw?)

---------

Co-authored-by: grepsuzette <grepsuzette@users.noreply.github.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
  • Loading branch information
3 people committed May 24, 2024
1 parent 8a728ff commit c6cde63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ install: install.gnokey install.gno install.gnodev
install.gnokey:
$(MAKE) --no-print-directory -C ./gno.land install.gnokey
# \033[0;32m ... \033[0m is ansi for green text.
@echo "\033[0;32m[+] 'gnokey' has been installed. Read more in ./gno.land/\033[0m"
@printf "\033[0;32m[+] 'gnokey' has been installed. Read more in ./gno.land/\033[0m\n"
.PHONY: install.gno
install.gno:
$(MAKE) --no-print-directory -C ./gnovm install
@echo "\033[0;32m[+] 'gno' has been installed. Read more in ./gnovm/\033[0m"
@printf "\033[0;32m[+] 'gno' has been installed. Read more in ./gnovm/\033[0m\n"
.PHONY: install.gnodev
install.gnodev:
$(MAKE) --no-print-directory -C ./contribs install.gnodev
@echo "\033[0;32m[+] 'gnodev' has been installed. Read more in ./contribs/gnodev/\033[0m"
@printf "\033[0;32m[+] 'gnodev' has been installed. Read more in ./contribs/gnodev/\033[0m\n"

# old aliases
.PHONY: install_gnokey
Expand Down

0 comments on commit c6cde63

Please sign in to comment.