From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26402 invoked by alias); 27 Feb 2015 12:09:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19928 Received: (qmail 12782 invoked from network); 27 Feb 2015 12:09:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dyne.org; s=mail; t=1425038963; bh=CModc7zLQ9hx3fb+oAEibk43GdepxYyTeNiyZEhXFLA=; h=Date:From:To:Subject:From; b=DGSSC7N12Nbkq2gGEO4OrnLeoYTkkD39Y1CrcifbTuglaiRNDy5uSL9JZ7toedjSt E76lwVAmnsuW2Qw8zAJy/++o9gBaL1LD3CVivPZR+rAdL/tZEcyL9yfPwGBtToR6Sm fREcZ+cSj0t+RNAxtE82J5ssm2jw7H65OTWkIOCo= Date: Fri, 27 Feb 2015 13:09:41 +0100 From: Jaromil To: zsh-users@zsh.org Subject: pointers and associative maps Message-ID: <20150227120941.GA15885@fork> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline Organization: Dyne.org Free Software Foundry X-GPG-Keyserver: pgp.mit.edu X-GPG-Id: 4ACB7D10 [expires: 2018-09-05] X-GPG-Fingerprint: 6113 D89C A825 C5CE DD02 C872 73B3 5DA5 4ACB 7D10 User-Agent: Jaro Mail --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable dear Zsh people, I'm an old-time (ab)user of ZSh (started using it back 15yrs ago on NetBSD), but this is the first time I interact with your lists since actually I never needed to, your documentation is too good :^). However, long due contact. Big up for ZSh release v5 BTW. I'm puzzled by a problem I encounter using pointers and associative maps. I want to use a variable as pointer for an associative map, then iterate through the map to get all its values, for saving it to a file and implement a simple load/save key/value store. The problem arises when I want to iterate through values, because using a pointer modifier (P) and key/value modifiers (k)|(v) I get out only the first char of the map field, not the whole string. I guess this is related to the scoping of modifiers? here is how I do it: # _map is the variable holding the name of the associative map _num=3D"${(P)#_map}" for c in {1..$_num}; do sysread -o 1 <> $_path $_map+=3D("${${(Pk)_map}[$c]}" "${${(Pv)_map}[$c]}") EOF presuming that ${${(Pk)_map}[$c]} and ${${(Pv)_map}[$c]} should give in res= ult the full string, but instead they return the first char of the string, as if the map index does not apply to the map but to the string object, so to say. Am I missing something here? Does anyone has clues? many thanks! --=20 Jaromil, Dyne.org Free Software Foundry (est. 2000) We are free to share code and we code to share freedom GPG: 6113 D89C A825 C5CE DD02 C872 73B3 5DA5 4ACB 7D10 ZShaolin - Power console terminal for Android https://play.google.com/store/apps/details?id=3Dorg.dyne.zshaolin Free binaries for ZSh developers, just ask me privately! --k+w/mQv8wyuph6w0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQQcBAEBCAAGBQJU8F6FAAoJEHOzXaVKy30QtjAf/2/y60Po2/4e3jN7Kzplwtaz 6BpOQFuKODEt/lij/pr+Cs396Yy5e7t96WhrQ2aVUfAAOTub/YWUzzsl+xMtuNbH EtEGRck+YP8ehzVm3Qw5zRz/6m0yCxBr7ITroOHzo6vQvk5MH+1NxULHtQkYGSFe OjfnI9s/TJ2yPWJxl1cN1Tvfsx/yVuycfrZKeHXfo1uAPN9d2/vXfLyYfzISZYOo UiAwYLyQv5L9V+WiaDFGoDza/5vU9Mw4eOrOhpi6vTk8UiQuSgwy5lrAnWhiz14i +Ko2/4AJTXFWKNUDbLwgNvTaSZW2lIkHNLNU2IgEhfdC4FTcctG0MPpV8+79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