From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 667951E5 for ; Thu, 28 Mar 2019 21:26:34 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,281,1549926000"; d="scan'208,217";a="376233413" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 28 Mar 2019 21:33:40 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 447148265D; Thu, 28 Mar 2019 21:33:40 +0100 (CET) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 58B0A8249D for ; Thu, 28 Mar 2019 21:33:33 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=matthew@o1labs.org; spf=None smtp.mailfrom=matthew@o1labs.org; spf=None smtp.helo=postmaster@mail-wm1-f51.google.com IronPort-PHdr: =?us-ascii?q?9a23=3ALWIwwhJhqg2wZY6lktmcpTZWNBhigK39O0sv0rFi?= =?us-ascii?q?tYgRL/TxwZ3uMQTl6Ol3ixeRBMOHsqoC27ad6vuwEUU7or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRp?= =?us-ascii?q?OOv1BpTSj8Oq3Oyu5pHfeQpFiCehbb9oLxi7ogrdutQYjIZhN6081gbHrnxUdu?= =?us-ascii?q?pM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTY?= =?us-ascii?q?QguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhT?= =?us-ascii?q?wZPDAl7m7Yls1wjLpaoB2/oRx/35XUa5yROPZnY6/RYc8WSW9HU81MVSJOH5m8?= =?us-ascii?q?YpMAAOoPP+lWr4fzqVgToxWgGQahH/ngxiNSi3LswaE2z+YsHAfb1wIgBdIOt3?= =?us-ascii?q?HUoc3yOqgITeC10KnIwivNbvhLxTn86JLHchY8qvyLWLJ/a9bRyVUvFwzbgFSd?= =?us-ascii?q?sovlMy6R1usXqGeb9PBsVeW1i24osgx8pCWkyMQ0ioTRmI4Z1lTJ+T96zYs1P9?= =?us-ascii?q?G0VVB3bN2+HJZQqi2XMZZ9TNk4TGFyoik6z6ULuZ6lcygOz5Qq3xvfZOaGc4iM?= =?us-ascii?q?+x7iWuORLSphiHJreL+zmgy+8Uenyu37Wcm01EhFojBZndnLs3ABzx3T6s6ZRf?= =?us-ascii?q?th5kqtxyqD2gTJ5uxHIU04j7fXJ4Aiz7IqlpcfrFzPHirsl0X3iK+WeF8k+u+t?= =?us-ascii?q?6+n/Z7XpvIOcN5N0ig7gPKUjgcu/Dfk8MgcURGeb4v6w1Lr5/U32WLlKlOE5kr?= =?us-ascii?q?HFsJDGIsQWvrK2DBVQ0oYn8hq/Czam0M8EnXQcN1JEeBeHj5DzNF3UIfD4C+2/?= =?us-ascii?q?g1W2nztxyfDGJO6pPpKYDnXHlar9NZxn4khQzEJnzd1b4o9ITLsbKfT/Xmf+sc?= =?us-ascii?q?yeCBIlZV+a2eHiXfB0yp8eVH3HOL6QNuuGtFaU+uIiPMGLPYscsi27LOIqsa29?= =?us-ascii?q?xUQlkEMQKPH6laAcb2q1S7E/ex3AMCjcx+wZGGJPhTIQCenjiVmMSzlWPizgWP?= =?us-ascii?q?s47zsgToW8AtWbH9z/sPm6xC6+W6ZuSCVeEFnVSyXvLoGNUexKbzidcJc4z240?= =?us-ascii?q?EIO5Qopk7imA8Q/3z709c7jR8ywc8I3mjZ17urSVmhY1+jh5Sc+a1jPVQg=3D?= =?us-ascii?q?=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AgBQBfLp1chjOAVdFlHAEBAQQBAQcEA?= =?us-ascii?q?QGBZYNJMyeEDoEdiwKHI4INkkWHGwNUD4RsAoU0GgYGNBIBAQMBAQkBAwEBARM?= =?us-ascii?q?BAQEICwsIKSMMgjopAYJnAQQBIx0BATcBBAsLBAEGJRICAiISAQUBDgENBhODI?= =?us-ascii?q?oFeAw0Inwc8iixxgS+CeAEBBYcqCBKBHYRdhlUXgX+BEYJkLj6BBAGBFYJ5gju?= =?us-ascii?q?CV5hoi2ZgCYJPkHgaaoEZiU+IOp5/DyGBQ4F3MxoIKAg7MQaCNYIKGAKDVIpTQ?= =?us-ascii?q?jABjUuCKQEB?= X-IPAS-Result: =?us-ascii?q?A0AgBQBfLp1chjOAVdFlHAEBAQQBAQcEAQGBZYNJMyeEDoE?= =?us-ascii?q?diwKHI4INkkWHGwNUD4RsAoU0GgYGNBIBAQMBAQkBAwEBARMBAQEICwsIKSMMg?= =?us-ascii?q?jopAYJnAQQBIx0BATcBBAsLBAEGJRICAiISAQUBDgENBhODIoFeAw0Inwc8iix?= =?us-ascii?q?xgS+CeAEBBYcqCBKBHYRdhlUXgX+BEYJkLj6BBAGBFYJ5gjuCV5hoi2ZgCYJPk?= =?us-ascii?q?HgaaoEZiU+IOp5/DyGBQ4F3MxoIKAg7MQaCNYIKGAKDVIpTQjABjUuCKQEB?= X-IronPort-AV: E=Sophos;i="5.60,281,1549926000"; d="scan'208,217";a="301086411" X-MGA-submission: =?us-ascii?q?MDG6vBEXjas3d3RIvmqu3E1RMjzteAflUV25lV?= =?us-ascii?q?etiQUTA71jCZO4zh4z1xT8d1BNehj7QAv8e8jMRMSv7ZJvnwBrc6Jozc?= =?us-ascii?q?MBfubVU5OljOY3kYmDqsd+01Wdy8004rlj0p6ofVqW+5/Gkx3iBMc5JB?= =?us-ascii?q?j3HX4dfQpxI/zR7YGe6aUrRA=3D=3D?= Received: from mail-wm1-f51.google.com ([209.85.128.51]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 28 Mar 2019 21:33:32 +0100 Received: by mail-wm1-f51.google.com with SMTP id h18so260368wml.1 for ; Thu, 28 Mar 2019 13:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o1labs-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TrUBryRG925nePfo3HFiFa74IWmGIrlejz7J47vLOwg=; b=CMRl23/HUy24bocPedsFjcMaxeeV9BTr/TYbPFVOKZ6ItFA4kjrwCMOHLViYAxaxFQ Et3cyWPrYfVNDZWva/hcRG9wco33tUHHAVEmeXfuaFBEBhWcL7agDAEMkoLcuIDsk4BI hJwPn/BzDwtIvmCkHHKOg0qIwTfkXM3uCca61PiK4kzFW0reS0QLlTDtKM9BDuqgsqDo RjXvy+TUj0j1qniDKECNzYb39ocLDvLx/3PHX4XWaewk3/V5HsvvXF5LuB57Og/1GLWo c8YlBaridGp0qlI/06JGEXKlh2okoUwmYIg+TIuzTCaLonbzrRHSDxXTn/CR4hQ0eUnR bmew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TrUBryRG925nePfo3HFiFa74IWmGIrlejz7J47vLOwg=; b=CQzvD5D/exMcww2R5v7T7RoHt+h70G6ij31ZV1DiaQXAGtf2j+cx/h2SWWTVLM5Anl /TweoG6irxxBZrS2niMEQlTtvPuWhUJKk7cn4YQaXPoVLLGNS3deK5xTNeVGgKwq8Yy0 kZ/pR0ypFk/tx/xlWS7gLl2gLQjsk5POoViSBPRwDjIacPYR154qNoZ6tBacYeryZjur p4ebkjXqK9FEg0xd9lTCHe4p3T1sczFdQEBYzGKKQ1aMFWqc2N36Pmu4kSy5GBQXVSlJ esgz96sTUnMdNlc94XrQEpJww0Mdno+nxHzeO+Rnm9LbmktwUgGLmq3GhZoAse8OUX08 hwng== X-Gm-Message-State: APjAAAWk54bVnBkGnNKjmK8BR5bNhPrpXNgkRJcyf6T4RnBidAtqhcAV sX5fr0MSIfuBhIurJG+3pQ0IdH3y/X9ynVnbejyDFw== X-Google-Smtp-Source: APXvYqzP3RidUvZMdjuGU2aCnLB/E9EZn8HmxXeex1dE+/2N91JzPuRjZkfnw6H7OCBYrQkuBFtX2MoutHgJSjJZuJI= X-Received: by 2002:a7b:c04c:: with SMTP id u12mr1237068wmc.71.1553805211438; Thu, 28 Mar 2019 13:33:31 -0700 (PDT) MIME-Version: 1.0 References: <21AC2517-8185-45A3-8520-53C92761CBBA@gmx.net> In-Reply-To: <21AC2517-8185-45A3-8520-53C92761CBBA@gmx.net> From: Matthew Ryan Date: Thu, 28 Mar 2019 20:33:20 +0000 Message-ID: To: Helmut Brandl Cc: caml users Content-Type: multipart/alternative; boundary="000000000000ada7a805852d7780" Subject: Re: [Caml-list] Turn echoing off on standard input to read e.g. passwords Reply-To: Matthew Ryan X-Loop: caml-list@inria.fr X-Sequence: 17440 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --000000000000ada7a805852d7780 Content-Type: text/plain; charset="UTF-8" Hi Helmut, The usual way to do this (for any language) is using ANSI escape sequences. Code 8 sets the terminal to conceal characters and code 0 resets the attributes, making them visible again. For example, in a unix shell you can test this with echo and read: echo -e '\x1b[8m'; read varname; echo -e '\x1b[0m' To do the same from OCaml, you can output "\x1b[8m", read the password, and then output "\x1b[0m" afterwards to switch printing back on. I believe that this will work on Windows 10, but earlier versions may not have the necessary ANSI support. Hope this helps, Matthew On Thu, 28 Mar 2019, 20:04 Helmut Brandl, wrote: > Hello list, > > Is there a portable way in ocaml to turn echoing off on standard input > from the terminal to read e.g. passwords? By portable I mean that it works > for Windows, Unix and Mac. > > Thanks for any hint. > > Regards > Helmut --000000000000ada7a805852d7780 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Helmut,

The usual way to do this (for any language) is using ANSI escape = sequences. Code 8 sets the terminal to conceal characters and code 0 resets= the attributes, making them visible again.

For example, in a unix shell you can test this with ech= o and read:

echo -e '= ;\x1b[8m'; read varname; echo -e '\x1b[0m'

To do the same from OCaml, you can output &q= uot;\x1b[8m", read the password, and then output "\x1b[0m" a= fterwards to switch printing back on.

I believe that this will work on Windows 10, but earlier vers= ions may not have the necessary ANSI support.

Hope this helps,
Matthew
On Thu, 28 Mar 2019, 20:04 Helmut Brandl, <helmut.brandl@gmx.net> wrote:
Hello list,

Is there a portable way in ocaml to turn echoing off on standard input from= the terminal to read e.g. passwords? By portable I mean that it works for = Windows, Unix and Mac.

Thanks for any hint.

Regards
Helmut
--000000000000ada7a805852d7780--