Homec4science

Support history in phutil_console_prompt()

Authored by vrana <jakubv@fb.com> on May 25 2012, 19:57.

Description

Support history in phutil_console_prompt()

Summary:
I've tried several approaches, this is the only one which works for me:

  • There's almost no chance that readline() will be available in PHP so I don't even check it.
  • I wasn't able to convince execx() to read the input.
  • I wasn't able to convince phutil_passthru() to give me the $REPLY or output.
  • Good old shell_exec() works.

I'm not sure if read -p supports colors but they are not much useful here.
I need to use read -p instead of echo otherwise the prompt is cleared with scrolling.

Test Plan:

phutil_console_prompt('Write:', '/tmp/history-test');
  • Run several times.
  • Input different strings.
  • Scroll in history.
  • Provide empty input.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2579

Details

Committed
vrana <jakubv@fb.com>May 25 2012, 20:42
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU4c4023a3ce5c: Create a script for killing __init__.php
Branches
Unknown
Tags
Unknown

Event Timeline

vrana <jakubv@fb.com> committed rPHU5cbe6191242e: Support history in phutil_console_prompt() (authored by vrana <jakubv@fb.com>).May 25 2012, 20:42