digitalmars.D - portability note: newlines
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (20/52) Feb 10 2005 Something that comes up time and time again
- Nick (7/13) Feb 10 2005 Just a comment: there isn't any consistent behaviour in linux. On the
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (6/13) Feb 10 2005 Moral of the story: always use explicit newlines :-)
Something that comes up time and time again is forgetting to finish console output with a newline character (either '\n' or using ln) This is *not* portable, unfortunately... On some systems, most notably Mac OS X, the output must be "terminated" with a newline character, or IT WILL NOT PRINT. And that's independant of the language used:echo -n hello print "hello" main() { printf("hello"); } import std.stdio; void main(char[][] args) { writef("hello"); }Each and everyone of these has same boring output: On other systems, such as Linux, they instead show: So, if you want Mac users to read your msg too, use:echo hello print "hello\n" main() { printf("hello\n"); } import std.stdio; void main(char[][] args) { writefln("hello"); }Thanks for listening... And _please_ change your code. --anders PS. I've already reported a bug against "sieve.d"... It doesn't find any primes on Mac OS X, because it forgets to add a "\n" newline after the printf.
Feb 10 2005
In article <cufbpq$1j8e$1 digitaldaemon.com>, =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...Each and everyone of these has same boring output: On other systems, such as Linux, they instead show:Just a comment: there isn't any consistent behaviour in linux. On the tty console or over shh, I get $ echo -n hello hello$ but on an xterm there is no output.
Feb 10 2005
Nick wrote:Just a comment: there isn't any consistent behaviour in linux. On the tty console or over shh, I get $ echo -n hello hello$ but on an xterm there is no output.Moral of the story: always use explicit newlines :-) As a side note, the programs do still output something so if you pipe it to something else it still shows up... Just that nothing is displayed to the user on the console. --anders
Feb 10 2005