delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/07/30/03:08:22

From: crandall AT matchlogic DOT com (Charles Randall)
Subject: B19.1: bash/sh/ash "read" bug
30 Jul 1998 03:08:22 -0700 :
Message-ID: <64003B21ECCAD11185C500805F31EC03A85ADC.cygnus.gnu-win32@houston.matchlogic.com>
Mime-Version: 1.0
To: "'gnu-win32 AT cygnus DOT com'" <gnu-win32 AT cygnus DOT com>
Cc: "'cfr AT pobox DOT com'" <cfr AT pobox DOT com>

The "read" builtin in bash/sh/ash doesn't seem to be functioning
properly. I suspect this has to do with newline processing on
stdin.

Anyway, consider the following test script (named test.sh):

  /bin/echo  "Q1 - [y/n] \c"
  read ans
  /bin/echo "ans=[$ans]"
  /bin/echo  "Q2 - [y/n] \c"
  read ans
  /bin/echo "ans=[$ans]"
  /bin/echo  "Q3 - [y/n] \c"
  read ans
  /bin/echo "ans=[$ans]"

With bash/sh/ash, I always get the following behavior:

  bash-2.01$ bash ./test.sh
  Q1 - [y/n] y
  ans=[y]
  Q2 - [y/n] ans=[]
  Q3 - [y/n] y
  ans=[y]

The second "read" returns nothing as if a newline had been entered.
I've tryed just entering "y" followed by either ^J or ^M as a guess.
That didn't work either.

Same behavior with or without the " \c" in the echo command.

This makes configuring Perl a real joy -- I only get a chance
to answer every other question from Configure. :^(

Suggestions? (I'm not interested in a binary distribution of Perl)

Charles

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019