digitalmars.D.learn - [beginner] Why nothing is printed to stdout ?
- =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> Oct 30 2011
- simendsjo <simendsjo gmail.com> Oct 30 2011
- Jesse Phillips <jessekphillips+d gmail.com> Oct 30 2011
- "Nick Sabalausky" <a a.a> Oct 30 2011
- "Mike James" <foo bar.com> Oct 30 2011
- =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> Oct 31 2011
- Dmitry Olshansky <dmitry.olsh gmail.com> Oct 30 2011
- =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> Oct 31 2011
- Kagamin <spam here.lot> Nov 01 2011
- Jonathan M Davis <jmdavisProg gmx.com> Nov 01 2011
- Kagamin <spam here.lot> Nov 02 2011
- "Nick Sabalausky" <a a.a> Nov 02 2011
- Kagamin <spam here.lot> Nov 03 2011
- Graham Fawcett <fawcett uwindsor.ca> Nov 01 2011
- "Nick Sabalausky" <a a.a> Nov 02 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Oct 31 2011
- Jude Young <10equals2 gmail.com> Nov 01 2011
- Graham Fawcett <fawcett uwindsor.ca> Nov 01 2011
- =?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> Nov 01 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Nov 02 2011
- Graham Fawcett <fawcett uwindsor.ca> Nov 02 2011
- "Jonathan M Davis" <jmdavisProg gmx.com> Nov 01 2011
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
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
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
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
"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
"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
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
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
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
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
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
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
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
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
"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 #!/bin/sh 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
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 #!/bin/sh 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
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
"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
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
Yet this silly stuff used to catch me all the time when switching fro=
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
--0016e659f09a2d343d04b0ad0b74 Content-Type: text/plain; charset=ISO-8859-1 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
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 ^_^
--0016e659f09a2d343d04b0ad0b74 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Ew.=A0 speak no blasphemy...<br><br><div class=3D"gmail_quote">On Tue, Nov = 1, 2011 at 6:27 AM, Kagamin <span dir=3D"ltr"><spam here.lot></span> = wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord= er-left:1px #ccc solid;padding-left:1ex;"> <div class=3D"im">Steven Schveighoffer Wrote:<br> <br> > Oh I remember doing that too :) =A0Don't feel bad, everyone does t= his at<br> > least once. =A0I hate that stupid test builtin, nobody ever uses it an= ymore.<br> ><br> > Note, it's not a command line tool, it's a shell builtin, whic= h is why it<br> > overrides anything in your search path.<br> ><br> > I've since adopted the habit of calling test programs "testme= " instead of<br> > "test" :)<br> <br> </div>Huh, must port windows console to linux ^_^<br> </blockquote></div><br> --0016e659f09a2d343d04b0ad0b74--
Nov 01 2011
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
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
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
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
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









=?iso-8859-1?b?RnLpZOlyaWM=?= Galusik <fredg salixosnospam.org> 