Olga,

The included man page show this option, and the implementation is AT&T.
I've done my test with UWin.

I agree that this option is not necessary and it seems that this is
not required by Single Unix Specifications.

Regards,

Yves

$ /usr/bin/stty --man
NAME
  stty - set or get terminal modes

SYNOPSIS
  stty [ options ] [mode ...]

DESCRIPTION
  stty sets certain terminal I/O modes for the device that is the current
  standard input; without arguments, it writes the settings of certain modes
  to standard output.

OPTIONS
  -a, --all       Writes to standard output all of the mode settings.
  -f, --fd=fd     Use fd as the terminal fd. The default value is 0.
  -g, --save      Writes the current settings to standard output in a form
                  that can be used as an argument to another stty command. The
                  rows and columns values are not included.
  -t, --terminal-group
                  Print the terminal group id of the device, -1 if unknown.

....
IMPLEMENTATION
  version         stty (AT&T Research) 2010-04-01
  author          Glenn Fowler <[email protected]>
  author          David Korn <[email protected]>
  copyright       Copyright (c) 1992-2010 AT&T Intellectual Property
  license         http://www.opensource.org/licenses/cpl1.0.txt
$

2010/5/27 ольга крыжановская <[email protected]>:
>
> Yves, AST stty has no --fd option.
>
> Olga
>
> On Thu, May 27, 2010 at 10:21 AM, Yves Crespin <[email protected]> 
> wrote:
>> Hello Roland,
>>
>> stdin is a terminal, you must set echo off (stty -echo).
>> I made few changes to deal with end of line and to be able to test it.
>>
>> Because you are reading caracters one by one, you are in a raw mode.
>> So you must deal with end-of-file.
>>
>> And ... I hard-code Ctrl-D as EOF.
>> I can get eof from stty, like :
>>    eof=$(stty -a | sed -n 's/eof = \([^;]*\);.*/\1/p')
>> But after, I need to change ^D to $'\cd' and I don't know how to do it!!
>>
>> Regards,
>>
>> Yves
>>
>> -- snip --
>> #!/bin/ksh
>> set -u
>> # line buffer class
>> # The buffer class tries to read characters from the given <fd> until
>> # it has read a whole line.
>> typeset -T linebuf_t=(
>>       typeset buf
>>
>>       function reset
>>       {
>>               _.buf=''
>>               return 0
>>       }
>>
>>       function readbuf
>>       {
>>               nameref var=$1
>>               integer fd=$2
>>               typeset ch
>>
>>               while read -u $fd -N 1 ch ; do
>>                        if [[ $ch == +($'\n'|$'\r'|$'\cd') ]]; then
>>                               var=${_.buf}
>>                               _.reset
>>                                [[ $var == '' ]] && return 1
>>                               return 0
>>                        fi
>>                        _.buf+=$ch
>>               done
>>
>>               return 1
>>       }
>> )
>>
>> integer infd
>> linebuf_t clientbuf
>>
>> redirect {infd}< '/dev/stdin'
>> stty --fd=$infd -echo
>>
>> trap 'stty --fd=$infd echo' EXIT
>>
>>       while clientbuf.readbuf line $infd ; do
>>               printf $"client: %q\n" "$line"
>>               printf '%s\n' "$line" >&$infd
>>       done
>> # End Of File
>> -- snip --
>>
>>
>> yves crespin
>>
>> On Wed, May 26, 2010 at 10:04 PM, Roland Mainz <[email protected]> 
>> wrote:
>>>
>>> Hi!
>>>
>>> ----
>>>
>>> Does anyone know why the example below echos the characters I type _twice_ ?
>>> -- snip --
>>> # line buffer class
>>> # The buffer class tries to read characters from the given <fd> until
>>> # it has read a whole line.
>>> typeset -T linebuf_t=(
>>>        typeset buf
>>>
>>>        function reset
>>>        {
>>>                _.buf=''
>>>                return 0
>>>        }
>>>
>>>        function readbuf
>>>        {
>>>                nameref var=$1
>>>                integer fd=$2
>>>                typeset ch
>>>
>>>                while IFS='' read -u${fd} -t 0.2 -N 1 ch ; do
>>>                        [[ "${ch}" == $'\r' ]] && continue
>>>
>>>                        if [[ "${ch}" == $'\n' ]] ; then
>>>                                var="${_.buf}"
>>>                                _.reset
>>>                                return 0
>>>                        fi
>>>
>>>                        _.buf+="$ch"
>>>                done
>>>
>>>                return 1
>>>        }
>>> )
>>>
>>> redirect {infd}< '/dev/stdin'
>>> linebuf_t clientbuf
>>>
>>> for (( ;; )) ; do
>>>        while clientbuf.readbuf line ${infd} ; do
>>>                printf $"client: %q\n" "${line}"
>>>                printf '%s\n' "${line}" >&${fd}
>>>        done
>>> done
>>> -- snip --
>>>
>>> If I run this script and enter "FISH" I get:
>>> FFIISSHH
>>>
>>> Erm... why does this happen ?
>>>
>>> ----
>>>
>>> Bye,
>>> Roland
>>>
>>> --
>>>  __ .  . __
>>>  (o.\ \/ /.o) [email protected]
>>>  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
>>>  /O /==\ O\  TEL +49 641 3992797
>>>  (;O/ \/ \O;)
>>> _______________________________________________
>>> ast-users mailing list
>>> [email protected]
>>> https://mailman.research.att.com/mailman/listinfo/ast-users
>>>
>>
>> _______________________________________________
>> ast-users mailing list
>> [email protected]
>> https://mailman.research.att.com/mailman/listinfo/ast-users
>>
>
>
>
> --
>      ,   _                                    _   ,
>     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
> .----'-/`-/     [email protected]   \-`\-'----.
>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>      /\/\     Solaris/BSD//C/C++ programmer   /\/\
>      `--`                                      `--`
>
>

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to