Created
August 13, 2011 05:32
-
-
Save drench/1143509 to your computer and use it in GitHub Desktop.
necho(): attempt echoing without a newline, under any common shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| necho() { | |
| echo -n "$*" | |
| } | |
| if [ -s "$BASH" ]; then | |
| e=`necho A; echo B` | |
| if [ "$e" != "AB" ]; then | |
| shopt -s xpg_echo | |
| necho() { | |
| echo "$*\c" | |
| } | |
| fi | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Built-in echo under OS X 10.6.8's /bin/sh doesn't honor "-n". /bin/sh is bash, though it's not the same as /bin/bash (the file sizes and contents are slightly different). There's some discussion about this at https://discussions.apple.com/thread/3177477 but no solution.