Thread overview | |||||
---|---|---|---|---|---|
|
July 23, 2016 How to pause terminal in D on Linux? | ||||
---|---|---|---|---|
| ||||
What I thought would be trivial is becoming a nightmare. Can anybody set me straight. Thanks in advance. void writeAndPause(string s) { writeln(s); // writeln("Press any key to continue..."); // works fine on Windows // executeShell("pause"); // works fine on Windows I tried the following read command and it works great in a Ubuntu shell: read -rsp $'Press any key to continue...\n' -n 1 key but when I put it in executeShell it doesn't pause and returns executeShell(`read -rsp $'Press any key to continue...\n' -n 1 key`); executeShell("read -rsp $'Press any key to continue...\n' -n 1 key"); returns /bin/sh: 1: read: Illegal option -s I tried the spawnShell... auto pid = spawnShell(`read -n1 -r -p "Press any key to continue..." key`); wait(pid); returns /bin/sh: 1: read: Illegal option -n } |
July 24, 2016 Re: How to pause terminal in D on Linux? | ||||
---|---|---|---|---|
| ||||
Posted in reply to WhatMeWorry | On Saturday, 23 July 2016 at 19:08:00 UTC, WhatMeWorry wrote:
> What I thought would be trivial is becoming a nightmare. Can anybody set me straight. Thanks in advance.
>
> [...]
Use the getchar() function.
void pause(const string msg = "Press enter/return to continue...")
{
write(msg);
getchar();
}
|
July 25, 2016 Re: How to pause terminal in D on Linux? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zekereth | On Sunday, 24 July 2016 at 00:54:21 UTC, Zekereth wrote:
> On Saturday, 23 July 2016 at 19:08:00 UTC, WhatMeWorry wrote:
>> What I thought would be trivial is becoming a nightmare. Can anybody set me straight. Thanks in advance.
>>
>> [...]
>
> Use the getchar() function.
>
> void pause(const string msg = "Press enter/return to continue...")
> {
> write(msg);
> getchar();
> }
just call std.stdio.stdin.read() and ignore the result...
|
Copyright © 1999-2021 by the D Language Foundation