may be bug

2011-08-08 Thread igor denisov

I am not sure if it a bug,

#!/bin/ksh
INFILENUM=$1

function read_line  {
  $
# Associate standard input with file descriptor 4
# and redirect standard input to $INFILENUM 
$


exec 40
exec 0 $INFILENUM 
$


read LINE
echo $LINE
  $
# Restore standard input and close file
# descriptor 4 
$


exec 04
exec 4-
}

read_line

output

read_line: ./num.sh[23]: $: not found
read_line: ./num.sh[23]: $: not found

may someone explain it
regards,
---


--
igor denisov.



Re: may be bug

2011-08-08 Thread Ingo Schwarze
Hi Igor,

igor denisov wrote on Mon, Aug 08, 2011 at 02:39:23PM +0400:

 I am not sure if it a bug,

It looks like a copy-and-paste bugs in your script.

 read_line: ./num.sh[23]: $: not found

Run hexdump -C on your script.
I see this, for example:

  23 21 2f 62 69 6e 2f 6b  73 68 0a 49 4e 46 49 4c  |#!/bin/ksh.INFIL|
0010  45 4e 55 4d 3d 24 31 0a  0a 66 75 6e 63 74 69 6f  |ENUM=$1..functio|
0020  6e 20 72 65 61 64 5f 6c  69 6e 65 20 20 7b 0a 20  |n read_line  {. |
0030  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  ||
*
0070  20 20 20 20 20 20 20 20  20 20 20 20 20 20 24 0a  |  $.|
0080  23 20 41 73 73 6f 63 69  61 74 65 20 73 74 61 6e  |# Associate stan|

And this:

00d0  74 6f 20 24 49 4e 46 49  4c 45 4e 55 4d 20 0a 24  |to $INFILENUM .$|
00e0  0a 0a 65 78 65 63 20 34  3c 26 30 0a 65 78 65 63  |..exec 40.exec|

If you put a dollar sign at the end of a line, no matter whether
there are lots of blanks before it or not, you need not wonder that
the shell tries to interpret the dollar sign as code.

Yours,
  Ingo