Q: FAQ? reading 8 bit input using bash

Q: FAQ? reading 8 bit input using bash

Post by w » Tue, 19 Apr 1994 06:07:54

Guess this one is good for a FAQ - but I did not find it there...

Is there a way to make bash accept 8 bit characters on input?



"UNIX was not designed to stop you from doing stupid things,  because
that would  also stop you from doing clever things."     -- Doug Gwyn


1. Bash calls TCL, TCL calls Bash, 2nd Bash never reads input

[fu-t set]

in comp.unix.misc i read:

perhaps you should resolve these deficiencies -- not that there is anything
wrong with using tcl from bash or bash from tcl, but it doesn't appear
necessary in this case.

in terms of shell scripting you don't have much debugging experience, in
particular you don't appear to have used ``set -vx'' to expose the
operations occurring.  which would lead to the real problem: you aren't
using enough quoting, which is causing ...

you have a test which expects certain arguments and they are not being
provided.  you use bare variable expansion, which does not result in an
argument being created if the variable is unset or empty.  let's look at
what that looks like using set -x.

my little test script, which is whittled down to just the problem, is:

  set -x
  [ $foo == 'Y' ]

executing this provides the following output:

  + foo=
  + '[' == Y ']'
  ./foo.sh: line 4: [: ==: unary operator expected

as you can see there is no argument before the == (which is non-standard
btw), because foo is empty.  to ensure that an argument is created you need
to use quotes, i.e.,

  set -x
  [ "$foo" == 'Y' ]

which after expansion becomes:

  + foo=
  + '[' '' == Y ']'

there we see that there is an empty argument being provided.

a signature

2. Loki Games

3. Getting User Input in BASH Script without using 'Read'.

4. pcmcia: bus pcmcia_bus_type, driver_socket as interface


6. Linking Pilot-link libs in gcc

7. reading user input with bash

8. MR BIOS V3.1.2 SHAREWARE BIOS for Intel Zappa Motherboard available

9. bash "read -a" ignores redirected input -- why?

10. Reading input with BASH

11. Q:NCSA's httpd_1.4.2 break on 8-bit input using METHOD=GET

12. Solution for "pipe output command into read variable" (see also bash faq E4)

13. SCSI 8-bit (read the FAQ & HOW TO)