Closed Sim4n6 closed 5 years ago
I would like to have this script running in all UNIX availiable. We're moving in that way. Outside from Linux, you can't take bash for granted. It's very popular and user friendly, but only /bin/sh is available in all *UX.
To get the full path of a command with type (type cat outputs cat is /bin/cat) could be done with which ( which bash outputs /bin/bash).
but COLORs will not be used in /bin/sh ... ? do we have to remove the coloring ?
Colours are given by ANSI scape sequences. Things like the TECRESET variable or "'\E[32m". It has notheing to do with the shell you choose to run your shellscripts.
Can you provide me with some documentation about that? Please
All systems have bash built in. Even basic ArchLinux have it. Sh is not provided "as is" nowdays. If you have a closer look, in Ubuntu, run ls -l /bin/sh . You will find it it is linked to /bin/dash . In Red Hat systems, if you run the same command, sh is linked to bash. I feel that sticking with bash as shebang will be persistent for all systems
All Linux systems have bash as default, I'm very aware of that fact. But we are working towards a script that is not only useful in Linux.
In AIX, most installs favour ksh (korn shell) but support Bourne Shell (/bin/sh). Solaris i recall that has bourne shell as default.
This are the reasons I insist on using bourne shell instead of bash.
2016-09-16 10:09 GMT-03:00 Atharva Deshmukh notifications@github.com:
All systems have bash built in. Even basic ArchLinux have it. Sh is not provided "as is" nowdays. If you have a closer look, in Ubuntu, run ls -l /bin/sh . You will find it it is linked to /bin/dash . In Red Hat systems, if you run the same command, sh is linked to bash. I feel that sticking with bash as shebang will be persistent for all systems
The ability to output colors is part of the terminal capabilities. If the terminal is unable to interpret ANSI scape sequences it will output garbage.
Look at this tiny script:
echo -e '\E[32m'"A Green Message"
It will run fine on Linux because of the terminal capabilities.
I've read, long time ago, about this on ncurses tutorials: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html . A good description about termcap (database&library) is on wikipedia: https://en.wikipedia.org/wiki/Termcap . Also is recomended to read about terminfo: https://en.wikipedia.org/wiki/Terminfo
Hope this answers your request.
2016-09-16 4:45 GMT-03:00 ALJI Mohamed notifications@github.com:
Can you provide me with some documentation about that? Please
the world is nice and wonderful , in theory of course.
I am using Terminator as an terminal emulator.
Well, when I switch to the shell SH (using bash -c or customizing config in Terminator )
I get strange \E[31m characters.
but It works like a charm under BASH , JUST SAYING :smile_cat:
It's not theory. Read what I've set you and take your conclusions. ;).
Please do this: execute echo $TERM
in both bash an sh. Then compare the outputs. We might take into account that many terminals doesn't support ANSI scape sequences.
echo $TERM
returns xterm-256color
If you choose
#!/bin/sh
as shebang , it will not support TYPE cmd.I prefer
#!/bin/bash
but a discussion will help figure out the right shebang