Is there an alternative of `go get`

2020-08-07 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi everyone,

`go get` in Golang world has a simple way to fetch and install 
binary


```
$ go get github/foo/bar.git
$ export PATH=$PATH:$(go env GOPATH)/bin
$ bar --help
```

This saves a lot of time and setup. Is that an alternative when 
using dub?


Thanks a lot.


Re: Which Docker to use?

2018-10-19 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 23:15:53 UTC, Jon Degenhardt 
wrote:


I need to use docker to build static linked Linux executables. 
My reason is specific, may be different than the OP's. I'm 
using Travis-CI to build executables. Travis-CI uses Ubuntu 
14.04, but static linking fails on 14.04. The standard C 
library from Ubuntu 16.04 or later is needed. There may be 
other/better ways to do this, I don't know.


Yes I'm also using Travis-CI and that's why I need some Docker 
support.


Which Docker to use?

2018-10-16 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I need to build some static binaries with LDC. I also need to 
execute builds on both platform 32-bit and 64-bit.



From Docker Hub there are two image groups:

* language/ldc (last update 5 months ago)
* dlang2/ldc-ubuntu (updated recently)


Which one do you suggest?

Thanks a lot.


Dlang on OpenWrt

2018-08-02 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

can I build my program on OpenWrt? I haven't found any resources 
on internet maybe I'm missing something.


Thanks a lot.


Is there a way to anonymously execute some sh script contents?

2018-08-01 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I have some big shell script that may require user input. Using 
`pipeProcess` doesn't work as `pipe` doesn't allow user to 
provide custom input (FIXME).


I am creating some temporary files, put the script contents to 
that file and then invoke


[code]
spawnProcess([/path/to/shell, /path/to/temporary/script/file]);
[/code]

This works well with user interaction. However I don't really 
like the idea of using temporary files. Is there any better way?


Thanks for your reading.


Re: Why does not UFCS work for method defined inside unittest block?

2018-08-01 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 31 July 2018 at 08:42:28 UTC, Simen Kjærås wrote:



From https://dlang.org/spec/function.html#pseudo-member:
"A free function can be called with a syntax that looks as if 
the function were a member function of its first parameter 
type."


 [...]


Thanks a lot Simen :)



Re: Why does not UFCS work for method defined inside unittest block?

2018-07-31 Thread Ky-Anh Huynh via Digitalmars-d-learn

dmd version that I'm using:

$ dmd --version
DMD64 D Compiler v2.081.1-dirty
Copyright (C) 1999-2018 by The D Language Foundation, All Rights 
Reserved written by Walter Bright




Why does not UFCS work for method defined inside unittest block?

2018-07-31 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

Can I define a new quick function to use inside a unittest block?

I have the following code:

[code]
auto foo(string[] sta) {
  return sta;
}

auto bar(string[] sta) {
  return sta;
}

auto h(string[] sta) {
  return sta.foo.bar;
}

unittest {
  import std.format;

  auto f = (string[] sta) => sta.foo.bar;
  auto g(string[] sta) {
return sta.foo.bar;
  }

  assert(f(["test"]) == ["test"]);
  assert(g(["test"]) == ["test"]);
  assert(["test"].h == ["test"]);
  assert(["test"].g == ["test"]);
}
[/code]

(Src: 
https://gist.github.com/icy/64ec1838929d448d9f874d1e8261e56a)


The last test will fail: Error: no property g for type string[]

Please advise.

Thanks a lot.





Re: Is it possible to have reproducible-builds?

2017-10-25 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Thursday, 26 October 2017 at 04:34:36 UTC, Ky-Anh Huynh wrote:

Hi,

I'd like to distribute binaries (compiled from Dlang sources) 
to my servers and users. This really helps end users because 
they don't need to rebuild things with custom dmd/dub setup. 
However, distributing things require them to `trust` me, and 
this is another thing I want to avoid.


Is it possible to have reproducible-builds with (any) dlang 
compiler? and how?


See also https://wiki.debian.org/ReproducibleBuilds

Thanks a lot for your reading.


See also the old topic: 
http://forum.dlang.org/thread/fsmdaethvbvcxnunb...@forum.dlang.org


Is it possible to have reproducible-builds?

2017-10-25 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I'd like to distribute binaries (compiled from Dlang sources) to 
my servers and users. This really helps end users because they 
don't need to rebuild things with custom dmd/dub setup. However, 
distributing things require them to `trust` me, and this is 
another thing I want to avoid.


Is it possible to have reproducible-builds with (any) dlang 
compiler? and how?


See also https://wiki.debian.org/ReproducibleBuilds

Thanks a lot for your reading.


Re: Writing some built-in functions for Bash, possible?

2017-10-21 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Wednesday, 18 October 2017 at 08:15:53 UTC, evilrat wrote:

[...]

This isn't the actual code but should give you a hint, the rest 
is up to you.


Woh Thanks a ton. I can have some working code after a few hours 
:D


https://github.com/icy/dusybox/blob/master/lib/dusybox/bash_builtin_hello/package.d

(A screenshot: 
https://github.com/icy/dusybox#a-bash-builtin-command)


I got problem with type conversion. I had to use inline 
declaration for `long_doc`:


```
extern(C) static builtin dz_hello_struct =
{
  name: cast (char*) "dz_hello",
  func: _hello_builtin,
  flags: BUILTIN_ENABLED,
  long_doc: [
"Hello, it's from Dlang.",
"",
"A Hello builtin command written in Dlang."
  ],
  short_doc: cast (char*) "dz_hello",
  handle: null
};
```

otherwise the compiler reports that some variable is not be read 
at compile time, or kind of `cannot use non-constant CTFE pointer 
in an initializer`.


There are many things I need to study from your post. So far it's 
good :)


Thanks again


Re: Writing some built-in functions for Bash, possible?

2017-10-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Wednesday, 18 October 2017 at 03:48:01 UTC, Ky-Anh Huynh wrote:

Some examples in C are in [2].

My experience: Dlang has `pipe` support however the syntax is 
not as clean as Bash :) Most of the times I see short (<1k loc) 
Bash scripts are easy to maintain than Ruby (and now D things) 
scripts.


And yeah writing in Bash has a lot of side effects ^.^


Writing some built-in functions for Bash, possible?

2017-10-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I'm using Bash heavily in my systems. Things become slow and slow 
when I have tons of scripts :) And sometimes it's not easy to 
manipulate data.


You may have heard of recutils [1] which has a C extension to be 
loaded by Bash. Is it possible to write similar things in D, for 
Bash? I am not good at C; it's great if I explore this field:)


Some examples in C are in [2].

My experience: Dlang has `pipe` support however the syntax is not 
as clean as Bash :) Most of the times I see short (<1k loc) Bash 
scripts are easy to maintain than Ruby (and now D things) scripts.


Thanks for your reading.

[1]: https://news.ycombinator.com/item?id=15302035
[2]: 
http://git.savannah.gnu.org/cgit/bash.git/tree/examples/loadables/cat.c


Re: How to modify process environment variables

2017-10-17 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 08:42:09 UTC, Rene Zwanenburg 
wrote:

On Tuesday, 17 October 2017 at 05:57:50 UTC, Ky-Anh Huynh wrote:

On Tuesday, 17 October 2017 at 04:56:23 UTC, ketmar wrote:


you can use libc's `putenv()` in D too, it is ok. just import 
`core.sys.posix.stdlib`,  it is there. D is not antagonistic 
to C, and doesn't try to replace the whole libc with it's own 
libraries. so if you see something that libc has and you'd 
like to use -- just do it! ;-)


I see :) I have always tried to avoid C if possible :D


As an alternative, a search on code.dlang.org turned up this 
lib:


http://code.dlang.org/packages/dotenv


Awesome. I will take a look definitely. I have a similar way in 
my NodeJS team :D


Re: How to modify process environment variables

2017-10-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 11:49:32 UTC, Jacob Carlborg wrote:

On 2017-10-17 06:51, Ky-Anh Huynh wrote:

Hi,

Is it possible to change the current process's environment 
variables?


I have looked at `std/process.d` source code, and there is 
only a private method `createEnv` used when new (sub)process 
is created.


In C `putEnv` the answer is positive: 
http://man7.org/linux/man-pages/man3/putenv.3.html (FIXME)


I come to this question as I want to set some custom variables 
for my unittests. My program reads some tokens from system 
environments, and it's convenient if I can simulate different 
cases for testings.


Thanks for your reading and support.


Use std.process.environment [1] and assign to it like an 
associative array.


[1] 
https://dlang.org/phobos/std_process.html#.environment.opIndexAssign


Oh thanks a lot for your pointing out, Jacob. That's the thing 
I'm looking for. The C version is not so bad though


```
  import core.sys.posix.stdlib;
  import std.string: toStringz;

  string jenkinsToken = "TEST_TOKEN=";
  putenv(cast(char*)jenkinsToken);
```



Re: How to modify process environment variables

2017-10-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 04:56:23 UTC, ketmar wrote:


you can use libc's `putenv()` in D too, it is ok. just import 
`core.sys.posix.stdlib`,  it is there. D is not antagonistic to 
C, and doesn't try to replace the whole libc with it's own 
libraries. so if you see something that libc has and you'd like 
to use -- just do it! ;-)


I see :) I have always tried to avoid C if possible :D




How to modify process environment variables

2017-10-16 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

Is it possible to change the current process's environment 
variables?


I have looked at `std/process.d` source code, and there is only a 
private method `createEnv` used when new (sub)process is created.


In C `putEnv` the answer is positive: 
http://man7.org/linux/man-pages/man3/putenv.3.html (FIXME)


I come to this question as I want to set some custom variables 
for my unittests. My program reads some tokens from system 
environments, and it's convenient if I can simulate different 
cases for testings.


Thanks for your reading and support.


How to embed static strings to a D program?

2017-10-15 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hello,

I want to use some static contents in my program, e.g, a CSS 
file, a long listing. To help deployment process I'd like to have 
them embedded in the final binary file.


Is there any convenient way to support this? Maybe I need a 
tool/library to load file contents and generate D-code at 
run-time ?


Thanks for your reading.


Re: Can I skip sub directories with file.dirEntries() ?

2017-09-27 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 10:05:34 UTC, Nicholas Wilson 
wrote:




I'd just use dirEntries with SpanMode.shallow in combination 
with filter either in a loop or a recursive function like below.


void foo(string path = "path")
{
foreach(e; 
dirEntries(path,SpanMode.shallow).filter!(myCritreia(paramters)))

{
if (e. isDir)
foo(e.name); // recurse
// do other stuff
}
}

you will loop over all subdirs of "path" that satisfy 
`myCritreia`.


Thank you Nicolas. It's a good idea.

PS: With Linux find command, the thing can be done easily with 
`-prune` option:


```
find . -iname node_modules -prune
```

Without `-prune` option, there are a lot of unnecessary sub 
directories...


Re: What does ! mean?

2017-09-27 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 14:34:06 UTC, Eugene Wissner 
wrote:


See also the following chapter in Ali's book:
http://ddili.org/ders/d.en/templates.html


Thanks a lot. I will keep reading :)



What does ! mean?

2017-09-27 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I am from Ruby world where I can have `!` (or `?`) in method 
names: `!` indicates that a method would modify its object 
(`foo.upcase!` means `foo = foo.upcase`). ( I don't know if there 
is any official Ruby documentation on this convention though. )


In D I see `!` quite a lot. I have read the first 50 chapters in 
Ali's book but nowhere I see a note on `!`. It's about the 
compile thing, isn't it? E.g,


```
foo = formattedRead!"%s"(value);
```

But I also see `!` for some map/filter invocations. It's quite 
confusing me.


Can you please explain and give any link where I can learn more 
about these things?


Thanks a lot.



Can I skip sub directories with file.dirEntries() ?

2017-09-27 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

Can I have a `break` option when using `dirEntries()`  (similar 
to `break` in a loop)? I want to study sub-directories but if any 
sub-directory matches my criteria I don't to look further into 
their subdirectories


```
  
 A/   -> matches criteria, stop here, go to next directory (B)
 B/   -> doesn't match criteria, will look at its 
sub-directories (BX, BY,...)

   BX
   BY
```

Thanks a lot


Re: How to list all process directories under /proc/

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 18:32:06 UTC, Matt Jones wrote:
On Tuesday, 19 September 2017 at 13:32:29 UTC, Ky-Anh Huynh 
wrote:




Btw, is that a bit weird that range is not supported in glob 
pattern :) Is there a design reason for this?


That is strange. But then again, every glob library I've seen 
works a little bit differently.


I see. Maybe I'm using Linux and Ruby too much. Missing character 
range doesn't really hurt, but the feature should be documented. 
Should we improve the documentation? To be fair, the syntax 
specification is clear after I read it twice, but the link to 
Wiki page is confusing, because Wiki page mentions the popular 
(FIXME) implementation with character range.


Re: formattedRead can't work with tab delimiter input

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 20:04:36 UTC, kdevel wrote:
On Tuesday, 19 September 2017 at 13:28:22 UTC, Ky-Anh Huynh 
wrote:

Hi,

I want to read two fields from STDIN

string key;
double value;
line_st.formattedRead!"%s %f"(key, value);


Well it's so different from C. I would use this:

---
auto t = line_st.split.join (' ');
t.formattedRead!"%s %f"(key, value);
---


Yes it's possible.

It's a little weird and it seems the "feature" (or bug) is not 
documented on https://dlang.org/phobos/std_format.html. Why a tab 
(`\t`) isn't considered as a space?


Re: How to list all process directories under /proc/

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 06:35:18 UTC, Matt Jones wrote:
On Sunday, 17 September 2017 at 08:37:33 UTC, Ky-Anh Huynh 
wrote:



[...]


The problem with matching "[0123456789]*" is that it will match 
files like "1blah" and "8stuff". It looks like glob patterns 
are not robust enough to handle match patterns you want. A 
regex would probably be enough. Something like this works:


[...]



I understand. Thanks a lot.

Btw, is that a bit weird that range is not supported in glob 
pattern :) Is there a design reason for this?


formattedRead can't work with tab delimiter input

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I want to read two fields from STDIN

string key;
double value;
line_st.formattedRead!"%s %f"(key, value);

However, if the input line contains \t and it doesn't contain any 
space, the code doesn't work as expected. If there is a space, it 
works well


   a[space]1 # work, key => a, value => 1
   b[space][tab]2# work, key => b, value => 2
   c[tab]3   # not work, key => c[tab]3, value => nan

Can you please help? Thanks a lot.


PS: My program is found here

https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L59


How to Skip some field/word in formattRead?

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

Is it possible to read just the second word from an input string 
and skip all others?


"one two three".formattedRead!("%s %s", _, saveme)

The point is I want to skip the first/third word (`one`, `third`) 
and read the second word (`two`) into the variable `saveme`. For 
now I have to declare temporary reference


string _;
"one two three".formattedRead!("%s %s %s", _, saveme, _);

Well, `_` is acceptable; in my example, the value of `_` would be 
`three[\n]`


Is there any better/cleaner way?

Thanks for your reading.


Re: How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Sunday, 17 September 2017 at 08:32:24 UTC, Ky-Anh Huynh wrote:


My bad. Range doesn't support. The correct pattern is

[code]
  foreach (string fstatm; dirEntries("/proc/", "[0123456789]*", 
SpanMode.shallow)) {

writefln("pid %s", fstatm);
  }
[/code]

Is there a way to make this simpler?


The official documentation here 
https://dlang.org/phobos/std_path.html#.globMatch refers to the 
wiki page https://en.wikipedia.org/wiki/Glob_%28programming%29 . 
However I think the popular glob rules (man 7 glob) are not 
supported.


Re: How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Sunday, 17 September 2017 at 08:15:58 UTC, Ky-Anh Huynh wrote:

Hi,

I want to list all processes by scanning /proc/. The following 
code doesn't work


[code]
  foreach (string fstatm; dirEntries("/proc/", "[0-9]*", 
SpanMode.shallow)) {

writefln("pid %s", fstatm);
  }
[/code]

as it only list a few entries before exiting

[code]
pid /proc/9
pid /proc/935
pid /proc/9146
pid /proc/9149
pid /proc/9150
pid /proc/9151
pid /proc/9756
pid /proc/9759
pid /proc/9760
pid /proc/9761
[/code]

I don't want to use `SpanMode.depth` or `SpanMode.breadth` 
because it will scan so deeply and there would be a permission 
problem.


Any ideas?

Thanks a lot


My bad. Range doesn't support. The correct pattern is

[code]
  foreach (string fstatm; dirEntries("/proc/", "[0123456789]*", 
SpanMode.shallow)) {

writefln("pid %s", fstatm);
  }
[/code]

Is there a way to make this simpler?





How to list all process directories under /proc/

2017-09-17 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I want to list all processes by scanning /proc/. The following 
code doesn't work


[code]
  foreach (string fstatm; dirEntries("/proc/", "[0-9]*", 
SpanMode.shallow)) {

writefln("pid %s", fstatm);
  }
[/code]

as it only list a few entries before exiting

[code]
pid /proc/9
pid /proc/935
pid /proc/9146
pid /proc/9149
pid /proc/9150
pid /proc/9151
pid /proc/9756
pid /proc/9759
pid /proc/9760
pid /proc/9761
[/code]

I don't want to use `SpanMode.depth` or `SpanMode.breadth` 
because it will scan so deeply and there would be a permission 
problem.


Any ideas?

Thanks a lot



Re: Convert user input string to Regex

2017-09-16 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:23:14 UTC, Adam D. Ruppe 
wrote:
On Saturday, 16 September 2017 at 03:18:31 UTC, Ky-Anh Huynh 
wrote:
Is there a way to transform user input string to a regular 
expression? For example, I want to write a `grep`-like program


import std.regex;

auto re = regex(user_pattern, user_flags);


You'll probably want to split it on the '/' to split the 
pattern and the flags since they are two separate variables to 
the regex function, but that's all you need to do.


http://dpldocs.info/experimental-docs/std.regex.regex.2.html



Thanks Adam. I will give it a try.


Convert user input string to Regex

2017-09-15 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

Is there a way to transform user input string to a regular 
expression? For example, I want to write a `grep`-like program


```
mygrep -E '/pattern/i' file.txt
```

and here the user's parameter `/pattern/i` would be converted to 
a Regex object.


Fyi, in Ruby, `to_regexp` is a useful gem: 
https://rubygems.org/gems/to_regexp


Thanks a lot.


Re: Unit-tests with stderr / stdout

2017-09-09 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Saturday, 9 September 2017 at 03:37:58 UTC, Ky-Anh Huynh wrote:

Hi,

As a system administrator I often have some small scripts/ 
programs that consume input and produce output for other system 
utilities. Something like `my_foo_program | awk ... | 
other_program`. As the tools write to STDOUT/STDERR, I haven't 
found a way to write unit tests for them. Should I write 
library instead? Is there any framework to write (smoke) tests 
that supports standard output devices?


Thanks for your reading.


So far I have refactored my code to use some public libraries. 
This allows me to write some unit tests. This requires a lot more 
work :)


Sorry for the noise.


Re: Should `dub run` prints its output to STDERR?

2017-09-09 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Saturday, 9 September 2017 at 05:58:59 UTC, Ali Çehreli wrote:

On 09/08/2017 09:51 PM, Ky-Anh Huynh wrote:
> When I execute a program thanks to dub, `dub` also prints its
> information to STDOUT:

Try dub's --quiet command line switch.

Ali


That's perfect. Thanks a lot.


Should `dub run` prints its output to STDERR?

2017-09-08 Thread Ky-Anh Huynh via Digitalmars-d-learn
When I execute a program thanks to dub, `dub` also prints its 
information to STDOUT:


[code]
$ dub run dusybox:jq -- .status "   1" < 
/home/pi/df/acces.log |head -10

Building package dusybox:jq in /home/pi/projects/icy/dusybox/
Performing "debug" build using dmd for x86_64.
dusybox:jq ~master: target for configuration "application" is up 
to date.

To force a rebuild of up-to-date targets, run again with --force.
Running ./dusybox_jq .status1
4031
4031
3021
[/code]

Those first 5 lines are generated by `dub` and written to STDOUT. 
This is a bit inconvenient if I want to use my program output as 
input for another program.


We may have the same program if `dub` writes to STDERR. But it's 
more sense that a pipe program uses STDIN for input. This is a 
popular behavior I think.


Is there any option other than redirecting which depends on shell 
support?


Thanks,


Unit-tests with stderr / stdout

2017-09-08 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

As a system administrator I often have some small scripts/ 
programs that consume input and produce output for other system 
utilities. Something like `my_foo_program | awk ... | 
other_program`. As the tools write to STDOUT/STDERR, I haven't 
found a way to write unit tests for them. Should I write library 
instead? Is there any framework to write (smoke) tests that 
supports standard output devices?


Thanks for your reading.


Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:56:20 UTC, Andrea Fontana 
wrote:
I used `lines(stdin)` as in 
https://dlang.org/phobos/std_stdio.html#.lines . My source 
code is here


https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 .

Thanks for your support.


I think formattedRead is consuming your string.


Great catch. You're right. Thanks a lot.

`strip()` returns a slice. I use another reference variable to 
save them and it's fine now.


[code]
auto line_st = line.strip();
auto line_st2 = line_st;


writefln("Stripped lined is %s", line_st2); // works fine
[/code]



Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote:


Maybe it has something to do with how you read from STDIN. Can 
you show that part of the code to see if I can reproduce the 
issue ?


I used `lines(stdin)` as in 
https://dlang.org/phobos/std_stdio.html#.lines . My source code 
is here


https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 
.


Thanks for your support.


Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I read line from STDIN , and strip them

[code]
auto line_st = line.strip();
[/code]


However, I can't use result in another format routine. Assume my 
input line is "foobar":


[code]
writeln("Stripped line is %s", line_st);
[/code]

This code only prints "Stripped line is ". If I use instead

[code]
writeln("Stripped line is %s", line.strip());
[/code]

the result is "Stripped line is foobar".

What're the difference between the two uses? I'm using `dmd 
v2.075.1`.


Thanks a lot.