I write a basic script which it has colourful lines in it.
#!/bin/bash
g="\e[32m"
_0="\e[0m"
printf "$g name $_0"
The script runs normally but at shellcheck.net I got this message: Don't use variables in the printf format string
.
Another problem when I convert my script to #!/bin/sh
my script doesn't run correctly, giving this output:
\e[32m name \e[0m
I used echo -e
but this time sh
said that -e
wasn't supported. How do I write a common line of code to solve this problem? Thank you.
bash
but not withsh
Is there a way that work with both? – Dec 17 '19 at 14:30