Re: [SLUG] shell oddities

From: Eben King (eben1@tampabay.rr.com)
Date: Tue Jan 06 2004 - 16:15:45 EST


On Tue, 6 Jan 2004, Kwan Lowe wrote:

> > #! /bin/bash
> > length="$1"
> > let hex_bytes=($length+1)/2
> > echo -n $(dd if=/dev/random bs=$hex_bytes count=1 2> /dev/null \
> > | od --address-radix=none --format=x \
> > | tr -d ' \n' \
> > | cut -b 1-$length)
> >
> > But the data never appears! The echo is executed (so says "set -x"). If
> > I add an echo after it, the buffer is flushed, but that defeats the point
> > of using "echo -n". What's wrong with this script? Thanks.
>
> Try this syntax instead:
>
> let hex_bytes=$[ (${length}+1)/2 ]

That's odd. I tried it that way (through PuTTY), it worked, so I put it
back, it worked. Heisenbug, I thought. So I went over to the machine.
No output in rxvt or xterm. Works on the console. XFree86 bug?

What does $[ ... ] signify? Like $(( ... )) in ksh?

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
CAPRICORN:  The stars say you're an exciting and wonderful person...
but you know they're lying.  If I were you, I'd lock my doors and
windows and never never never never leave my house again.  -- Weird Al

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:12:36 EDT