package term

import (
	
	
)

// readPasswordLine reads from reader until it finds \n or io.EOF.
// The slice returned does not include the \n.
// readPasswordLine also ignores any \r it finds.
// Windows uses \r as end of line. So, on Windows, readPasswordLine
// reads until it finds \r and ignores any \n it finds during processing.
func ( io.Reader) ([]byte, error) {
	var  [1]byte
	var  []byte

	for {
		,  := .Read([:])
		if  > 0 {
			switch [0] {
			case '\b':
				if len() > 0 {
					 = [:len()-1]
				}
			case '\n':
				if runtime.GOOS != "windows" {
					return , nil
				}
				// otherwise ignore \n
			case '\r':
				if runtime.GOOS == "windows" {
					return , nil
				}
				// otherwise ignore \r
			default:
				 = append(, [0])
			}
			continue
		}
		if  != nil {
			if  == io.EOF && len() > 0 {
				return , nil
			}
			return ,  //nolint:wrapcheck
		}
	}
}