www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [beginner] Why nothing is printed to stdout ?

reply =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> writes:
Hi,

Can someone give me a clue on why nothing is printed to stdout ?

I wish a list of files with their size.
 
code:
//
import std.stdio;
import std.file;

void main(string[] args)
{
    foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
    {
        writeln(e.name, "\t", e.size);
    }
}
//
Build with (dmd2):
dmd -w test.d
Oct 30 2011
next sibling parent reply simendsjo <simendsjo gmail.com> writes:
On 30.10.2011 11:00, Frédéric Galusik wrote:
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
      foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
      {
          writeln(e.name, "\t", e.size);
      }
 }
 //
 Build with (dmd2):
 dmd -w test.d
Works for me on 2.055 and 2.056 on windows. What compiler and OS are you using? c:\temp>dmd -w test.d c:\temp>test|more .\.a.d.un~ 5326 .\.asciidoc_user-guide.txt.un~ 942 (...)
Oct 30 2011
parent =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> writes:
Le Sun, 30 Oct 2011 12:17:24 +0100, simendsjo a écrit :

 Works for me on 2.055 and 2.056 on windows. What compiler and OS are you
 using?
 
 c:\temp>dmd -w test.d
 c:\temp>test|more
 .\.a.d.un~      5326
 .\.asciidoc_user-guide.txt.un~  942
 (...)
Tested with dmd 2.055 and now 2.056 on Linux ++
Oct 30 2011
prev sibling next sibling parent Jesse Phillips <jessekphillips+d gmail.com> writes:
On Sun, 30 Oct 2011 10:00:21 +0000, Frédéric Galusik wrote:

 Hi,
 
 Can someone give me a clue on why nothing is printed to stdout ?
 
 I wish a list of files with their size.
  
 code:
 //
 import std.stdio;
 import std.file;
 
 void main(string[] args)
 {
     foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
     {
         writeln(e.name, "\t", e.size);
     }
 }
 //
 Build with (dmd2):
 dmd -w test.d
works for me, dmd 2.054 linux.
Oct 30 2011
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Frédéric Galusik" <fredg salixosnospam.org> wrote in message 
news:j8j77l$pfv$1 digitalmars.com...
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
    foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
    {
        writeln(e.name, "\t", e.size);
    }
 }
 //
 Build with (dmd2):
 dmd -w test.d
My aplogies it you already know this, It's not my intention to be patronizing: You did run the resulting executable, right ( ./test )? And there are files in the dir its beng run from?
Oct 30 2011
next sibling parent "Mike James" <foo bar.com> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:j8kd11$25v1$1 digitalmars.com...
 "Frédéric Galusik" <fredg salixosnospam.org> wrote in message 
 news:j8j77l$pfv$1 digitalmars.com...
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
    foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
    {
        writeln(e.name, "\t", e.size);
    }
 }
 //
 Build with (dmd2):
 dmd -w test.d
My aplogies it you already know this, It's not my intention to be patronizing: You did run the resulting executable, right ( ./test )? And there are files in the dir its beng run from?
And you did run it in a DOS window or from a batch file with a PAUSE to allow you to read the output ;-)
Oct 30 2011
prev sibling parent =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> writes:
Le Sun, 30 Oct 2011 16:44:20 -0400, Nick Sabalausky a écrit :

 "Frédéric Galusik" <fredg salixosnospam.org> wrote in message
 news:j8j77l$pfv$1 digitalmars.com...
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
    foreach (DirEntry e; dirEntries(".", SpanMode.shallow)) {
        writeln(e.name, "\t", e.size);
    }
 }
 //
 Build with (dmd2):
 dmd -w test.d
My aplogies it you already know this, It's not my intention to be patronizing: You did run the resulting executable, right ( ./test )? And there are files in the dir its beng run from?
Don't need to apologize, it's already kind to answer ;) So, Yes I run the resulting executable in my $HOME dir where there are many files. If I run it through Geany (IDE) I only got: ------------------ (program exited with code: 1) Press return to continue If I run in my terminal, there's no output. ++ fredg
Oct 31 2011
prev sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 30.10.2011 14:00, Frédéric Galusik wrote:
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
      foreach (DirEntry e; dirEntries(".", SpanMode.shallow))
      {
          writeln(e.name, "\t", e.size);
      }
 }
 //
 Build with (dmd2):
 dmd -w test.d
I might be way off on this. Yet this silly stuff used to catch me all the time when switching from windows to *nixes, back and forth: sh$: compile something to 'test' sh$: test no output - WTF? Ahem, it just called that command line tool named test... sh$: ./test wow, now something happens ;) -- Dmitry Olshansky
Oct 30 2011
parent reply =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> writes:
Le Mon, 31 Oct 2011 00:55:58 +0400, Dmitry Olshansky a écrit :

 On 30.10.2011 14:00, Frédéric Galusik wrote:
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
      foreach (DirEntry e; dirEntries(".", SpanMode.shallow)) {
          writeln(e.name, "\t", e.size);
      }
 }
 //
 Build with (dmd2):
 dmd -w test.d
I might be way off on this. Yet this silly stuff used to catch me all the time when switching from windows to *nixes, back and forth: sh$: compile something to 'test' sh$: test no output - WTF? Ahem, it just called that command line tool named test... sh$: ./test wow, now something happens ;)
Ohhh yesss, you got it. That was so stupid, a big thanks. Regards. ++ fredg
Oct 31 2011
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 31 Oct 2011 06:01:05 -0400, Fr=C3=A9d=C3=A9ric Galusik  =

<fredg salixosnospam.org> wrote:

 Le Mon, 31 Oct 2011 00:55:58 +0400, Dmitry Olshansky a =C3=A9crit :

 On 30.10.2011 14:00, Fr=C3=A9d=C3=A9ric Galusik wrote:
 Hi,

 Can someone give me a clue on why nothing is printed to stdout ?

 I wish a list of files with their size.

 code:
 //
 import std.stdio;
 import std.file;

 void main(string[] args)
 {
      foreach (DirEntry e; dirEntries(".", SpanMode.shallow)) {
          writeln(e.name, "\t", e.size);
      }
 }
 //
 Build with (dmd2):
 dmd -w test.d
I might be way off on this. Yet this silly stuff used to catch me all the time when switching fro=
m
 windows to *nixes, back and forth:

 sh$: compile something to 'test'
 sh$: test
 no output - WTF? Ahem, it just called that command line tool named
 test... sh$: ./test
 wow, now something happens ;)
Ohhh yesss, you got it. That was so stupid, a big thanks. Regards.
Oh I remember doing that too :) Don't feel bad, everyone does this at = least once. I hate that stupid test builtin, nobody ever uses it anymor= e. Note, it's not a command line tool, it's a shell builtin, which is why i= t = overrides anything in your search path. I've since adopted the habit of calling test programs "testme" instead o= f = "test" :) -Steve
Oct 31 2011
parent reply Kagamin <spam here.lot> writes:
Steven Schveighoffer Wrote:

 Oh I remember doing that too :)  Don't feel bad, everyone does this at  
 least once.  I hate that stupid test builtin, nobody ever uses it anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is why it  
 overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme" instead of  
 "test" :)
Huh, must port windows console to linux ^_^
Nov 01 2011
next sibling parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Tuesday, November 01, 2011 04:27 Kagamin wrote:
 Steven Schveighoffer Wrote:
 Oh I remember doing that too :) Don't feel bad, everyone does this at
 least once. I hate that stupid test builtin, nobody ever uses it
 anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is why it
 overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme" instead of
 "test" :)
Huh, must port windows console to linux ^_^
No. No. We must port Windows users to Linux. ;) - Jonathan M Davis
Nov 01 2011
prev sibling next sibling parent Jude Young <10equals2 gmail.com> writes:
Ew.  speak no blasphemy...

On Tue, Nov 1, 2011 at 6:27 AM, Kagamin <spam here.lot> wrote:

 Steven Schveighoffer Wrote:

 Oh I remember doing that too :)  Don't feel bad, everyone does this at
 least once.  I hate that stupid test builtin, nobody ever uses it
anymore.
 Note, it's not a command line tool, it's a shell builtin, which is why it
 overrides anything in your search path.

 I've since adopted the habit of calling test programs "testme" instead of
 "test" :)
Huh, must port windows console to linux ^_^
Nov 01 2011
prev sibling parent reply Graham Fawcett <fawcett uwindsor.ca> writes:
On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:

 Steven Schveighoffer Wrote:
 
 Oh I remember doing that too :)  Don't feel bad, everyone does this at
 least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is why
 it overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme" instead
 of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :) Graham
Nov 01 2011
next sibling parent =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> writes:
Le Tue, 01 Nov 2011 18:23:52 +0000, Graham Fawcett a écrit :

 On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:
 
 Steven Schveighoffer Wrote:
 
 Oh I remember doing that too :)  Don't feel bad, everyone does this at
 least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is why
 it overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme" instead
 of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :) Graham
Excellent :D ++
Nov 01 2011
prev sibling next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, November 01, 2011 18:23:52 Graham Fawcett wrote:
 On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:
 Steven Schveighoffer Wrote:
 Oh I remember doing that too :)  Don't feel bad, everyone does this at
 least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is why
 it overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme" instead
 of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :)
Though if you don't get used to putting ./ in front of the names of binaries that you're running in the current directory, you're going to have other problems. The suggestion does fix the occasional screw-up with that particular command though. - Jonathan M Davis
Nov 01 2011
next sibling parent Graham Fawcett <fawcett uwindsor.ca> writes:
On Tue, 01 Nov 2011 12:18:02 -0700, Jonathan M Davis wrote:

 On Tuesday, November 01, 2011 18:23:52 Graham Fawcett wrote:
 On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:
 Steven Schveighoffer Wrote:
 Oh I remember doing that too :)  Don't feel bad, everyone does this
 at least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.
 
 Note, it's not a command line tool, it's a shell builtin, which is
 why it overrides anything in your search path.
 
 I've since adopted the habit of calling test programs "testme"
 instead of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :)
Though if you don't get used to putting ./ in front of the names of binaries that you're running in the current directory, you're going to have other problems. The suggestion does fix the occasional screw-up with that particular command though.
Agreed; if you're going to use a system, learn how to use it properly. Then again, there's no shame in using "training wheels" if you're an absolute beginner. When I started using Unix, I was glad that the "dir" command was available on the system I was using. (I'm not sure if it was a binary, or whether a kindly sysop had provided an alias to "ls" for us Windows users). Learning is a journey of many small steps! Graham
Nov 01 2011
prev sibling parent reply Kagamin <spam here.lot> writes:
Jonathan M Davis Wrote:

 Though if you don't get used to putting ./ in front of the names of binaries 
 that you're running in the current directory, you're going to have other 
 problems. The suggestion does fix the occasional screw-up with that particular 
 command though.
Seems like ./ tries to fix some sort of Namespace Pollution Hell when virtually every installed program ends up in path.
Nov 02 2011
parent reply "Nick Sabalausky" <a a.a> writes:
"Kagamin" <spam here.lot> wrote in message 
news:j8rlig$145l$1 digitalmars.com...
 Jonathan M Davis Wrote:

 Though if you don't get used to putting ./ in front of the names of 
 binaries
 that you're running in the current directory, you're going to have other
 problems. The suggestion does fix the occasional screw-up with that 
 particular
 command though.
Seems like ./ tries to fix some sort of Namespace Pollution Hell when virtually every installed program ends up in path.
It's also a safety/security matter. Imagine: $ cat ./ls rm ~ -rf Gee, let's see what's inside this directory...WTF? God dammit!! Windows generally gets away without such problems because even the power users usually stick to the GUI for most stuff, and also because extensive shell scripting is generally avoided.
Nov 02 2011
parent Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 Seems like ./ tries to fix some sort of Namespace Pollution Hell when 
 virtually every installed program ends up in path.
It's also a safety/security matter. Imagine: $ cat ./ls rm ~ -rf Gee, let's see what's inside this directory...WTF? God dammit!! Windows generally gets away without such problems because even the power users usually stick to the GUI for most stuff, and also because extensive shell scripting is generally avoided.
It's ok to have a limited set of "keyword-class" tools in global namespace, but not every installed program. For example, on windows you don't have firefox or git or dmd in path (by default). You don't run dmd in arbitrary directory just to see what it will do.
Nov 03 2011
prev sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 01 Nov 2011 14:23:52 -0400, Graham Fawcett <fawcett uwindsor.ca>  
wrote:

 On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:

 Steven Schveighoffer Wrote:

 Oh I remember doing that too :)  Don't feel bad, everyone does this at
 least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.

 Note, it's not a command line tool, it's a shell builtin, which is why
 it overrides anything in your search path.

 I've since adopted the habit of calling test programs "testme" instead
 of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :)
That's a cool trick :) However, one issue, if you do happen to run any shell scripts where some a**hole insisted on using test instead of the [] form, this will cause problems. There must be some way to check for an interactive shell... -Steve
Nov 02 2011
next sibling parent Graham Fawcett <fawcett uwindsor.ca> writes:
On Wed, 02 Nov 2011 07:56:19 -0400, Steven Schveighoffer wrote:

 On Tue, 01 Nov 2011 14:23:52 -0400, Graham Fawcett <fawcett uwindsor.ca>
 wrote:
 
 On Tue, 01 Nov 2011 07:27:44 -0400, Kagamin wrote:

 Steven Schveighoffer Wrote:

 Oh I remember doing that too :)  Don't feel bad, everyone does this
 at least once.  I hate that stupid test builtin, nobody ever uses it
 anymore.

 Note, it's not a command line tool, it's a shell builtin, which is
 why it overrides anything in your search path.

 I've since adopted the habit of calling test programs "testme"
 instead of "test" :)
Huh, must port windows console to linux ^_^
Too much work! Just put alias test='./test' in your .profile, and be happy. :)
That's a cool trick :) However, one issue, if you do happen to run any shell scripts where some a**hole insisted on using test instead of the [] form, this will cause problems. There must be some way to check for an interactive shell...
I can't speak for all shells, but bash and zsh don't expand aliases when you run a script. From the bash manual: Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below). Cheers, Graham
Nov 02 2011
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message 
news:op.v4bh35eaeav7ka localhost.localdomain...
 On Tue, 01 Nov 2011 14:23:52 -0400, Graham Fawcett <fawcett uwindsor.ca> 
 wrote:
 Too much work! Just put

   alias test='./test'

 in your .profile, and be happy. :)
That's a cool trick :) However, one issue, if you do happen to run any shell scripts where some a**hole insisted on using test instead of the [] form, this will cause problems. There must be some way to check for an interactive shell...
The delicious irony is that if they had decided to use test instad of [], it was probably for the sake of maximizing compatibility.
Nov 02 2011