[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: manpage error-Arithmetic Evaluation of numbers with explicit base
From: |
Greg Wooledge |
Subject: |
Re: manpage error-Arithmetic Evaluation of numbers with explicit base |
Date: |
Mon, 29 Mar 2010 08:51:18 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Mar 29, 2010 at 02:22:35PM +0200, Thomas Bartosik wrote:
> Well OK, I understand. Still I think there should be a difference in the man
> page when it comes to brackets. When talking about arrays, the brackets are
> NOT an option but mandatory.
That's correct. Referencing a specific element of an array by index
uses square brackets as part of the syntax.
> (and it might be me being uneducated, but how to you print out the decimal
> equivalent of binary 11 without using brackets? I can only produce the
> correct value "3" by
> echo $[2#11]
The $((...)) notation is preferred and documented.
echo $((2#11))
> The "optional" refers to being able to not use it when operating on a normal
> decimal number as I understand this now. Then where can I find that I have to
> use brackets like I use them -- which only is a side effect of the brackets I
> have seen in the man page and seems unrelated on the whole!)
You are confusing literal square brackets which are part of the syntax
of a command (as in array indexing) with the brackets used in man pages
and other documents to indicate that something is optional.
We're not saying that literal square brackets are optional when doing
array indexing. We're saying that the things INSIDE brackets in a man
page are optional -- and that the brackets themselves are NOT part of
the command at all, but rather, part of the documentation.
I understand how it's easy to get confused by that, but eventually
you'll have to get used to it.
Look at ls(1) from Debian as an example:
SYNOPSIS
ls [OPTION]... [FILE]...
Or from HP-UX:
SYNOPSIS
ls [-abcdefgilmnopqrstuxACFLR1] [names]
Or from OpenBSD:
SYNOPSIS
ls [-1AaCcdFfghikLlmnopqRrSsTtux] [file ...]
See the brackets there? They indicate that the options and filenames
are optional. They don't mean that you type literal square brackets
around the options and filenames.
What is $[ ] ?, Marc Herbert, 2010/03/23