bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Aw: currently doable? Indirect notation used w/a hash


From: John Kearney
Subject: Aw: currently doable? Indirect notation used w/a hash
Date: Sat, 15 Jun 2013 15:03:19 +0200 (CEST)

   In bash there are 2 options that I use.

   1.
   ArrayName=blah

   printf -V "${ArrayName}[Index]" "%s" "Value To Set"


   2.
     ks_val_ChkName() {
       local LC_COLLATE=C
       case "${1:?Missing Variable Name}" in
         [!a-zA-Z_]* | *[!a-zA-Z_0-9]* | '' ) return 3;;
       esac
     }
      ks_array_SetVal() {
         ks_val_ChkName "${1:?Missing Array Name}" || return $?
         ks_val_ChkName "a${2:?Missing Array Index}" || return $?
         eval "${1}"["${2}"]'="${3:-}"'
       }
   ks_array_SetVal "${ArrayName}" "Index" "Value"

   Cheers

   Gesendet: Sonntag, 09. Juni 2013 um 23:02 Uhr
   Von: "Linda Walsh" <bash@tlinx.org>
   An: bug-bash <bug-bash@gnu.org>
   Betreff: currently doable? Indirect notation used w/a hash
   I was wondering if I was missing some syntax somewhere...
   but I wanted to be able to pass the name of a hash in
   and store stuff in it and later retrieve it... but it
   looks like it's only possible with an eval or such?
   Would be nice....(??)*sigh*


reply via email to

[Prev in Thread] Current Thread [Next in Thread]