Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 20:40, L A Walsh  wrote:
>
> I seebut that begs the question, how do you access an array's
> members using a var holding the array's name?
>
> I wanted to be able to do something like have a set of
> values in an assoc. map, and pass the name to a generic
> processing routine with the map name as a param, like:
>
> sub processSrvState() {
>my stat=${1:?}
>if [[ ${!stat[cur_up]} == ${!stat[max_up]} &&
>  ${!stat[cur_down]} == ${!stat[max_down]} ]]; then
>  ...
>fi

processSrvState() {
  local cur_up="$1[cur_up]"
  local max_up="$1[max_up]"
  if [[ "${!cur_up}" == "${!max_up}" ]] ; then
echo ok
  fi
}

declare -A foo=([cur_up]=11 [max_up]=11)

processSrvState foo

# note that the array name must not conflict with any keys



Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 11:50, L A Walsh  wrote:
>
> I'm a bit confused ...
> If I have assoc-array:
>
>  declare -A foo=([one]=11 [two]=22)
>
> and am passing name in another var, like "fee"
>
>  fee=foo
>
> I tried echoing the val:
>
>  echo ${!fee[one]}
>
> but got nothing -- tried a few other syntaxes.

I think this does what you want ...

$ declare -A foo=([one]=11 [two]=22)
$ fee=foo[one]
$ echo "${!fee}"
11



Re: PDF documentation output not readable (3.2.6 GNU Parallel)

2018-05-10 Thread David Margerison
On 11 May 2018 at 07:35, Quentin L'Hours  wrote:
> On 2018-05-10 02:24 PM, Greg Wooledge wrote:
>> Oh... well, it's not in the manual (bash(1)).  It's in this
>> other thing called the "Bash Reference Manual", apparently at
>> 
>
> This is the html version of the info documentation if I'm not mistaken, You
> can see it from your terminal with:
> info bash 'Basic Shell Features' 'Shell Commands' 'GNU Parallel'

Yes, on Debian stable I can see that text after installing the bash-doc package
and running:
  info -f bash -n "GNU Parallel".



Re: suggestion for improvement - help pwd

2018-06-02 Thread David Margerison
On 3 June 2018 at 09:54, Chet Ramey  wrote:
> On 6/2/18 2:19 PM, jefg...@protonmail.com wrote:
>> Dear Sir or Madam,
>>
>> I'd like to make a somewhat meticulous suggestion for improvement in the 
>> output of 'help pwd'.
>> On line 6, the word 'directory' is not properly indented.
>
> It looks fine to me:

And it looks broken to me.

I tested on

$ echo $BASH_VERSION
4.3.30(1)-release

interactively, and then by running this command

$ help pwd >filename

Viewing the created file in an editor that makes tab and space
characters individually visible reveals that the line in question is
indented using a mixture of spaces and tabs.

Whereas every other line is indented by space characters only.

So in many situations, affected by font and tab-width settings,
the line 6 will therefore fail to match the indentation of the other lines.

It looks like if an extra four leading spaces were added to that line,
then it would correctly align always.

I hope this helps :)